C#,如何只获取 GET 参数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11684571/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
C#, how to get only GET parameters?
提问by BuZz
System.Web.HttpContext.Current.Request.Paramsseems 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 参数?
采纳答案by Allen Xia
use Request.QueryString Collection for GET paras and Request.Form Collection for POST ones.
将 Request.QueryString 集合用于 GET 参数,将 Request.Form 集合用于 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).aspxand 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

