C#,如何只获得GET参数?

时间:2021-11-12 21:36:12

System.Web.HttpContext.Current.Request.Params seems to return way too many params, including headers, etc... How can I efficiently only retrieve GET or POST parameters ?

System.Web.HttpContext.Current.Request.Params似乎返回了太多的参数,包括标题等...我怎样才能有效地只检索GET或POST参数?

1 个解决方案

#1


24  

use Request.QueryString Collection for GET paras and Request.Form Collection for POST ones.

使用Request.QueryString Collection for GET paras和Request.Form Collection for POST。

e.g.

例如

var someValueFromGet = Request.QueryString["YourGetPara"];
var someValueFromPost = Request.Form["YourPostPara"];

please refer to http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx and http://msdn.microsoft.com/en-us/library/ms525985(v=vs.90).aspx

请参阅http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx和http://msdn.microsoft.com/en-us/library/ms525985(v= VS.90)的.aspx

#1


24  

use Request.QueryString Collection for GET paras and Request.Form Collection for POST ones.

使用Request.QueryString Collection for GET paras和Request.Form Collection for POST。

e.g.

例如

var someValueFromGet = Request.QueryString["YourGetPara"];
var someValueFromPost = Request.Form["YourPostPara"];

please refer to http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx and http://msdn.microsoft.com/en-us/library/ms525985(v=vs.90).aspx

请参阅http://msdn.microsoft.com/en-us/library/ms524784(v=vs.90).aspx和http://msdn.microsoft.com/en-us/library/ms525985(v= VS.90)的.aspx