今天一通道技術反映我們提交過去的url太長了,形如:
在日志中找了相應的記錄,日志如下:
並沒有多提交內容,最后發現原因是對方使用HttpContext.Current.Request.Params獲取參數值。我們先來看一個例子:
Response.Write(HttpContext.Current.Request["url"]);
1).http://localhost:1043/net/Send.aspx不帶參數時結果:
/net/Send.aspx //說明:Request.ServerVariables["url"]
/net/Send.aspx //說明:Request.ServerVariables["url"]
2).http://localhost:1043/net/Send.aspx?url=http://www.mzwu.com/帶參數時結果:
http://www.mzwu.com/,/net/Send.aspx //說明:Request.QueryString["url"],Request.ServerVariables["url"]
http://www.mzwu.com/ //說明:Request.QueryString["url"]
現在非常清楚了,我們來查看下官方兩個方法的說明吧:
HttpContext.Current.Request.Params是獲取 System.Web.HttpRequest.QueryString、System.Web.HttpRequest.Form、System.Web.HttpRequest.ServerVariables 和 System.Web.HttpRequest.Cookies 項的組合集合;
HttpContext.Current.Request是從System.Web.HttpRequest.Cookies、System.Web.HttpRequest.QueryString、System.Web.HttpRequest.Form 和 System.Web.HttpRequest.ServerVariables 集合中獲取指定的對象。
所以上邊的問題只需將HttpContext.Current.Request.Params改為HttpContext.Current.Request即可。