2014-01-22 39 views
0

我在Speedway閱讀器中使用RFID Speedway連接軟件,我得到了HTTP Post的PHP示例,並在google搜索了一段時間後,找不到.Net C#的示例。所以我嘗試了簡單的asp.net應用程序[在IIS中託管]來接收讀者的HTTP post響應,但我從未接受過。HTTP Post在高速公路連接軟件中使用.Net C#

以下是我的示例代碼。在讀者分配

網址是http://MY_IP/Default.aspx

我的asp.net代碼示例是:

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(); 
} 

我的頁面永遠不會腹背受敵。任何人都可以告訴我如何在C#中實現HTTP Post響應。

感謝

回答

0

嘗試使用通用處理器

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; } 
    } 
}