尝试使用ActionLink
助手的正常过载(是的,有过载的gazillions):
@Html.ActionLink(
"Sign Out", // linkText
"LogOff", // actionName
"Account", // controllerName
null, // routeValues
new { @class = "btn blue" } // htmlAttributes
)
,而你使用:
@Html.ActionLink(
"Sign Out", // linkText
"LogOff", // actionName
"Account", // routeValues
new { @class = "btn blue" } // htmlAttributes
)
了解为什么你的代码不管用?
是的,微软对这些超负荷做了一个混乱,如果你不小心,你陷入陷阱。
解决方案:读取MSDN
或使用Visual Studio智能感知(F12,而您的光标在ActionLink助手上)。
出于这个原因,我更愿意把它写在使用C#4.0的命名参数的模式明确的方式:
@Html.ActionLink(
linkText: "Sign Out",
actionName: "LogOff",
controllerName: "Account",
routeValues: null,
htmlAttributes: new { @class = "btn blue" }
)
啊,达林拍我来吧 – pinmonkeyiii