今天一通道技术反映我们提交过去的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即可。