0

I am using RFID Speedway connect software in the Speedway reader, I got a PHP sample for HTTP Post and after googled sometime I couldn't find the sample for .Net C#. So I tried in simple asp.net application[hosted in IIS] to receive the HTTP post response from the reader but I never get in to it.

Below is my sample code.

URL assigned in the reader is http://MY_IP/Default.aspx

My asp.net code sample is :

protected void Page_Load(object sender, EventArgs e)
{    
        System.Text.StringBuilder displayValues =     new System.Text.StringBuilder();
        System.Collections.Specialized.NameValueCollection postedValues = Request.Form;
        Label1.Text = postedValues.AllKeys.Length.ToString();
}

my page never got hit. Can anyone tell me how to achieve the HTTP Post response in C#.

Thanks

Prabhakaran
  • 1,264
  • 2
  • 20
  • 47

1 Answers1

0

Try using a generic handler

myHandler.ashx

public class myHandler : IHttpHandler
{
   public void ProcessRequest(HttpContext context)
    {
        string requestStr= new StreamReader(context.Request.InputStream).ReadToEnd();

        context.Response.ContentType = "application/text";

        switch (context.Request.HttpMethod)
        {
            case "GET":

                break;
            case "POST":
                context.Response.Write("ok");
                break;
            default:
                break;
        }
    }

    public bool IsReusable
    {
        get { return false; }
    }
}