asp.net mvc - MVC Html.ActionLink removes empty querystring parameter from URL -


i'm using html.actionlink(string linktext, string actionname, object routevalues) overload send params action method..

sometimes need pass empty parameter value like: ?item1=&item2=value

i'm specifying param in anonymous type create , pass routevalues, both null , string.empty result in url omits empty item1 param.

new { item1 = null, item2 = "value" }  new { item1 = string.empty, item2 = "value" } new { item1 = "", item2 = "value" }  // result in: ?item2=value 

i can create url manually want use helper method.

suggestions?

create emptyparameter class follows:

public class emptyparameter {     public override string tostring()     {         return string.empty;     } } 

then:

@html.actionlink("action",                  "controller",                   new { item1 = new emptyparameter(), item2 = "value" }); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -