Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC - Adding querystring "length=" to ActionLinks?

I have a few ActionLinks that when rendered are getting a length key/value added that appears to indicate the number of characters of the controller name. How can this be removed?

like image 692
ScottG Avatar asked Apr 21 '10 20:04

ScottG


4 Answers

At a guess, you are probably using the wrong overload of Html.ActionLink and are adding to the route parameters instead of the HTML attributes. You need to add a NULL as the fourth parameter before your specify the HTML attributes. Something like:

 Html.ActionLink("Title", "Action", "Controller", null ,new { title = "Title"} )

Post your code if this doesn't work.

like image 116
Dan Diplo Avatar answered Nov 17 '22 03:11

Dan Diplo


you need stick stick an extra empty object parameter in before the htmlattributes, something like this off the top of my head

 html.actionlink("a","b","c",new {},new {@class = "d"})
like image 29
Paul Creasey Avatar answered Nov 17 '22 02:11

Paul Creasey


Check to see if your using the right overload for Html.ActionLink.

They get tricky because they take any object, even anonymous ones, and transform those into route value dictionaries or html attributes depending on the overload your using. Since it will run and compile fine if you mess these two up its hard to tell if your using the right overload.

like image 2
John Farrell Avatar answered Nov 17 '22 03:11

John Farrell


If you are passing 'routeValues',

Make sure that 'htmlAttributes' is set to null.

 Html.ActionLink("Title", "Action", "Controller", new {}, null )

Else wrong overload of AcitonLink is picked.

like image 1
Shyam Poovaiah Avatar answered Nov 17 '22 01:11

Shyam Poovaiah