1

Hi im quite new to MVC 5 but not .net c#

im having a issue with @Html.ActionLink

the links keep adding 'Length=10' on the end

this is my link

@Html.ActionLink("Reporting", "Reporting", "MenuRouter", new { @class = "Reporting" }, new { hidefocus = "hidefocus" })

Iv tried moving things about and I still get the 'Length=10' on the end

any help Thanks Tim

  • Have you searched this on SO? It has been answered many times [here](http://stackoverflow.com/q/824279/1199711), [here](http://stackoverflow.com/q/2686260/1199711), [here](http://stackoverflow.com/q/4357856/1199711)... – Zabavsky Jul 31 '14 at 10:19
  • @Zabavsky yes I did still had many problems, its on here to many time with so many solutions and couldn't figure out one that was going to help me :( i have fixed it now –  Jul 31 '14 at 10:23
  • @Zabavsky plus some that I have looked at are for MVC 3 and 4 but im sorry I am new to this. –  Jul 31 '14 at 10:27

2 Answers2

2

Try this;

@Html.ActionLink("Reporting", "Reporting", "MenuRouter", null, new { @class = "Reporting", hidefocus = "hidefocus" })
Saranga
  • 3,178
  • 1
  • 18
  • 26
1

Ok the reason is because; the MVC pipeline is trying to serialize a string object, via the actionlink method

The method calls this:

public static string ActionLink (this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes)

Your best bet is to try and using a new {} on the controller try this:

@Html.ActionLink("Reporting", "Reporting", new { Controller = "MenuRouter"}, new { @ID = "Repoting" ,  hidefocus = "hidefocus" })     

This will certainly remove the Length=10 this is happening because there is no routes stated with a length, the property value and name will be appended and the query string parameter.

The above should fix your issue. Alan

AlanMorton2.0
  • 1,043
  • 2
  • 12
  • 22