Search code examples
c#asp.nethttp-request-parameters

C# Asp.net string values HttpRequestHeader


I send data to the API via HttpRequestHeader (post)
The server response is:

code1=7ea12f&code2=3867&code3=123&code4=104

I need to string each value to view them in separate label.

label1.text = code1;
label2.text = code2;
label3.text = code3;
label4.text = code4;

Solution

  • You can do this:

    var nameValueCollection = System.Web.HttpUtility.ParseQueryString("code1=7ea12f&code2=3867&code3=123&code4=104");
    
    label1.text = nameValueCollection["code1"];
    label2.text = nameValueCollection["code2"];
    label3.text = nameValueCollection["code3"];
    label4.text = nameValueCollection["code4"];