我有这个动作链接:
@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 =
我已经生成了这个动作链接:
mysite.com/Members/Export?regionId=%2C67
因某些原因,%2C
被添加到regionId
,但我不确定。谁知道我做错了什么?
答案 0 :(得分:2)
%2相当于一个空格,您的代码中可能有一个空格。