显示子'长度= 10'的MVC 5 Link问题

时间:2014-07-31 10:16:28

标签: c# asp.net-mvc

嗨,我对MVC 5很新,但不是.net c#

我遇到@Html.ActionLink

的问题

链接继续在末尾添加“长度= 10”

这是我的链接

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

我尝试了一些事情,我仍然得到了“长度= 10”的结尾

任何帮助谢谢蒂姆

2 个答案:

答案 0 :(得分:2)

试试这个;

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

答案 1 :(得分:0)

好的原因是因为; MVC管道试图通过actionlink方法

序列化一个字符串对象

该方法称之为:

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

最好的办法是尝试在控制器上使用new {}试试这个:

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

这肯定会删除Length=10这种情况,因为没有带长度的路由,附加属性值和名称以及查询字符串参数。

以上内容应该可以解决您的问题。艾伦