J'ai une URL comme ceci:Supprimer le nom d'action de l'URL et ajouter la page titre à l'URL - Asp.net MVC
http://localhost:17594/Contact/Contact
Maintenant, je veux montrer comme ceci:
http://localhost:17594/Contact/Contact-us
RouteConfig :
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Categories",
url: "Categories/{id}",
defaults: new { controller = "Categories", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "FinalKaminet.Controllers" }
);
routes.MapRoute(
name: "Contacts",
url: "{controller}/{title}",
defaults: new { controller = "Contact", action = "Contact", title = UrlParameter.Optional },
namespaces: new[] { "FinalKaminet.Controllers" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}/{title}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional , title = UrlParameter.Optional },
namespaces: new[] { "FinalKaminet.Controllers" }
);
}
Voir
@Html.ActionLink("Contact Us", "Contact" , "Contact" , new { title = "contact-us" } , null)
Mais j'ai une erreur dans la ligne 63 qui utilise Categories
carte route.
Exception Details: System.InvalidOperationException: No route in the route table matches the supplied values.
Source Error:
Line 62: @Html.ActionLink("وبلاگ", "")
Line 63: @Html.Action("MenuCat" , "Home")
Qu'est-ce qui ne va pas?