【发布时间】:2011-05-29 23:18:52
【问题描述】:
我一直在谷歌搜索以找到一种从 URL 读取参数值的方法,但没有成功。在 ASP.NET Webform 中,我们使用 Request.Querystring["name"] 来获取值。如何在 MVC3 中做到这一点?
我需要访问 HtmlHelper 类中的参数。任何人请。
互联网上对此没有明确的答案。奇怪……
【问题讨论】:
标签: url asp.net-mvc-3 parameters query-string
我一直在谷歌搜索以找到一种从 URL 读取参数值的方法,但没有成功。在 ASP.NET Webform 中,我们使用 Request.Querystring["name"] 来获取值。如何在 MVC3 中做到这一点?
我需要访问 HtmlHelper 类中的参数。任何人请。
互联网上对此没有明确的答案。奇怪……
【问题讨论】:
标签: url asp.net-mvc-3 parameters query-string
我仍然在 MVC3 中使用HttpContext.Current.Request.QueryString...
if (!Request.QueryString["ParameterName"].IsEmpty())
{
// Do something only if URL parameter "ParameterName" is not empty...
}
例如:
http://192.168.1.106:7777/Measurement?sort=FatPercentage&sortdir=DESC
if (!Request.QueryString["sort"].IsEmpty())
{
// sort=FatPercentage. It's not empty and this code block will be executed
}
【讨论】: