【发布时间】:2018-07-02 14:38:46
【问题描述】:
我在 ASP.Net MVC 5 中的控制器上有以下操作:
[Route("Sprache/{languageName}/Kurs/{courseName}/Text/{value}/Test/{referenzID}", Name = "Textauswahl")]
public ActionResult SelectedText(string languageName, string courseName, string value, string referenzID)
{
return View("ShowTextView");
}
但是,当我尝试通过以下链接生成链接时,它始终为空。
<a href="@Url.RouteUrl("Textauswahl", new { Model.Training.LanguageName, Model.Training.CourseName, Model.Training.Category ,item })">Auswählen</a>
这是我的 RouteConfig:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
【问题讨论】:
标签: c# asp.net asp.net-mvc asp.net-mvc-4 razor