0

I have this action link:

@Html.ActionLink("Export to Excel",  // link text
    "Export",                        // action
    "Members",                       // controller
    Request.QueryString,             // query string
    "excel");                        // class

Using my own overloaded Action Link method:

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();
}

So this is the url of the page on my on:

mysite.com/Members?searchName=&searchEmail=&agencyId=&agencyTypeId=&regionId=&regionId=67&searchTaxIdNum=&searchDateStart=&searchDateEnd=

And the Action Link I have generates this url:

mysite.com/Members/Export?regionId=%2C67

So for some reason %2C is getting added to the regionId, but I'm not sure. Anyone know what I'm doing wrong?

1 Answer 1

2

%2 in a URL is equivalent to a blank space, you probably have a blank space somewhere in your code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.