我正在传递empid,我希望它显示在url中,但它显示为querystring:
<li>@Html.ActionLink(key.Value, "Attendance","HOD", new {empid=key.Key}, null)
</li>
我想要显示的链接如下:
/HOD/Attendance/xyz%2Fabc
但它显示我这样:
/HOD/Attendance?empid=xyz%2Fabc //it's like query string but i don't want that.
有人可以帮忙吗?我很感激任何帮助。非常感谢。
我已将此RouteMap添加到Global.asax
routes.MapRoute (
"HOD_AttByEmpID", // Route name
"{controller}/{action}/{empid}", // URL with parameters
new { controller = "Account", action = "LogOn",
empid = UrlParameter.Optional }
);
答案 0 :(得分:2)
@Html.ActionLink(key.Value, "Attendance","HOD", new { key.Key},null)
答案 1 :(得分:1)
我想这是因为你的价值包含'/'
也许你可以试试:
<li>@Html.ActionLink(key.Value, "Attendance","HOD",
new {empid=Server.UrlEncode(key.Key)}, null)
</li>