Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving a HTTP POST in HTTP Handler?

I need to listen and process a HTTP POST string in a HTTP handler.

Below is the code for posting the string to handler -

string test = "charset = UTF-8 & param1 = val1 & param2 = val2 & param3 = val3 & param4 = val4;
byte[] data = Encoding.UTF8.GetBytes(test);
PostData("http://localhost:53117/Handler.ashx", data);

What I tried in Handler is -

    public void ProcessRequest(HttpContext context)
    {
        var value1 = context.Request["param1"];
    }

But its null. How can I listen and get the parameter values in Handler?

like image 556
Sandy Avatar asked Jun 08 '13 06:06

Sandy


1 Answers

Change

    var value1 = context.Request["param1"];

to

    var value1 = context.Request.Form["param1"];
like image 80
Ratna Avatar answered Oct 05 '22 10:10

Ratna