public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "",
url: "{url}",
defaults: new { controller = "Home", action = "Index", url = "index" }
);
//routes.MapRoute(
// name: "",
// url: "{url}",
// defaults: new { controller = "Card", action = "Index", url = (string)null }
//);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
@Html.ActionLink("Главная (normal)", "Index", "Home")
@Html.ActionLink("Главная", "Index", "Home", new { url = "index" }, null)
@Html.ActionLink("Карточка (normal)", "Index", "Card")
@Html.ActionLink("О сайте (normal)", "About", "Home")
@Html.ActionLink("О сайте", "Index", "Home", new { url = "about" }, null)
routes.MapRoute(
name: "",
url: "", // <-- пустой URL
defaults: new { controller = "Home", action = "Index", parameter = "index" }
);
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "",
url: "",
defaults: new { controller = "Home", action = "Index", parameter = "index" }
);
routes.MapRoute(
name: "",
url: "{parameter}",
defaults: new { controller = "Home", action = "Index", parameter = (string)null }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "",
url: "{parameter}",
defaults: new { controller = "Home", action = "Index", parameter = (string)null }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
public ActionResult Index(string parameter = "index")
{
switch (parameter)
{
case "about": return RedirectToAction("About");
default:
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
}
@Html.ActionLink("Главная", "Index", "Home")
@Html.ActionLink("О сайте", "Index", "Home", new { parameter = "about" }, null)
@Html.ActionLink("О сайте (normal)", "About", "Home")
<configuration>
<system.web>
<globalization culture="ru-RU" uiCulture="ru-RU" />
</system.web>
</configuration>