Answer the question
In order to leave comments, you need to log in
Customizing Url Parameter Routing with ASP.NET MVC Default Action?
Hello @user.Name
I have the following RouteConfig method:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Catalog",
url: "Catalog/{category}",
defaults: new { controller = "Catalog", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
public ActionResult Index(string category)
{
return View(category);
}
@model string
@{
ViewBag.Title = Model;
}
@Model
Server error in application '/'.
The view 'Test' or its instance could not be found, or no view engine supports search locations. The following locations were searched:
~/Views/Catalog/Test.aspx
~/Views/Catalog/Test.ascx
~/Views/Shared/Test.aspx
~/Views/Shared/Test.ascx
~/Views/Catalog/Test. cshtml
~/Views/Catalog/Test.vbhtml
~/Views/Shared/Test.cshtml
~/Views/Shared/Test.vbhtml
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question