2013-06-04 38 views
1

我想讀取Aspx頁面中Sencha Touch 2的POST參數。從Sencha Touch 2讀取Asp.net中的POST參數

Aspx從Sencha Touch Framework(由移動應用程序團隊)按以下方式調用。

Ext.Ajax.request({ 

      url:'http://bookingsite.com/flight/Secure_Payment.aspx', 
      method:'POST', 
      disableCaching: false, 
      headers: { 
     'Accept': 'application/json', 
     'Content-Type': 'application/json' 
      }, 
      jsonData: { 
      uniqueID:"24608b55-3f69-4814-9de3-ebc88fa95700", 
      totalFare:"3500" 
      }, 
      success:function(response) 
      { 
      console.log(response.responseText); 
      } 
      failure:function(response) 
      { 
      console.log(response); 
      }});  

煎茶觸摸的POST參數是通過在Asp.net(Secure_Payment.aspx)通過以下方式

protected void Page_Load(object sender, EventArgs e) 
{ 
    // Tried by the following ways. 

    string uniID = HttpContext.Current.Request.Form["uniqueID"]; 
    string uniID = HttpContext.Current.Request["uniqueID"]; 
    string uniID = HttpContext.Current.Request.Form.Get("uniqueID"); 

    if (!string.IsNullOrEmpty(uniID)) 
     { 
      ds = balLayer.GetEBSPaymentParams("uniID"); 
     } 

     tripID=ds.Rows[0]["TripID"].ToString(); 
     name = ds.Rows[0]["ContactFname"].ToString(); 
} 

讀到這裏,數據集總是返回空值。

請通知我如何閱讀Aspx頁面中的POST參數。

+1

你要反序列化Request.InputStream。請參閱http://stackoverflow.com/questions/3398926/how-to-retrieve-json-via-asp-net-context-request – sjkm

+0

@sjkm感謝您的信息。我會盡力而爲。 – Thiri

回答

0

嘗試用params屬性,而不是jsonData:

Ext.Ajax.request({ 
    ... 
    params: { 
     uniqueID:"24608b55-3f69-4814-9de3-ebc88fa95700", 
     totalFare:"3500" 
    }, 
    ... 

http://docs.sencha.com/touch/2.2.1/#!/api/Ext.Ajax

+0

我會試一試你的代碼。 POST方法是否支持Params? – Thiri

+1

是的,實際上,如果你不指定'方法',並且如果'params'存在,它將默認爲POST,否則爲GET –