我有这个动作链接:
@Html.ActionLink("Export to Excel", // link text
"Export", // action
"Members", // controller
Request.QueryString, // query string
"excel"); // class
使用我自己的重载 Action Link 方法:
public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper,
string linkText, string action, string controllerName,
NameValueCollection queryString, string className)
{
var newRoute = new RouteValueDictionary();
IDictionary<string, object> htmlAttributes =
new Dictionary<string, object> {{"class", className}};
newRoute = htmlHelper.ViewContext.HttpContext.Request.QueryString.ToRouteDic(newRoute);
return HtmlHelper.GenerateLink(htmlHelper.ViewContext.RequestContext,
htmlHelper.RouteCollection, linkText, null, action, null,
newRoute, htmlAttributes).ToMvcHtml();
}
所以这是我的页面的网址:
mysite.com/Members?searchName=&searchEmail=&agencyId=&agencyTypeId=®ionId=®ionId=67&searchTaxIdNum=&searchDateStart=&searchDateEnd=
我拥有的 Action Link 生成了这个 url:
mysite.com/Members/Export?regionId=%2C67
所以由于某种原因%2C
被添加到 中regionId
,但我不确定。有人知道我在做什么错吗?