Add query string as route value dictionary to ActionLink

Try this:

I'm not sure this is the cleanest or most correct way but it does work

I didn't use your extension method. You'll have to reintegrate that:

@{ 
    RouteValueDictionary tRVD = new RouteValueDictionary(ViewContext.RouteData.Values);
    foreach (string key in Request.QueryString.Keys ) 
    { 
        tRVD[key]=Request.QueryString[key].ToString();
    }
}

then

@Html.ActionLink("Export to Excel",    // link text
"Export",                          // action name
"GridPage",                      // controller name
tRVD, 
new Dictionary<string, object> { { "class", "export" } }) // html attributes

Results in

Results

with class exportenter image description here


If you look here: http://msdn.microsoft.com/en-us/library/system.web.mvc.html.linkextensions.actionlink.aspx

//You are currently using:
ActionLink(HtmlHelper, String, String, String, Object, Object)
//You want to be using:
ActionLink(HtmlHelper, String, String, String, RouteValueDictionary, IDictionary<String, Object>)