将查询字符串参数传递到.NET MVC中的Action方法



我有

的方法
 UrlHelper.Action("login", "Authentication", HttpContext.Current.Request.Url.Scheme);

我想传递查询字符串参数,例如"推荐人?"=该方法的PAGENAME。我该怎么做?

您只需要像这样删除参数:

UrlHelper.Action("login", "Authentication", new { referrer = "Page Name" })

然后在您的操作中获取参数:

Request.Params["referrer"]

示例

Url.Action("GetValues", "Home", new { Area = "Solan", id =Model.Id})

此处的区域和ID是传递到Home Controller内部的GetValues方法的参数

最新更新