An awesome routing engine for ASP.NET MVC 3 and 4
Routeattribute, along with the URL you wish. The format of the URL resembles the one used by ASP.NET to identify a virtual path, so the tilde symbol (
~) may be used as a placeholder for the root directory.
~/a-very-interesting-actionis defined for the MVC action:
public class FooBarController : Controller { [Route.Action("~/a-very-interesting-action")] public ActionResult Baz() { // TODO: Make something useful return Content("hello, world"); } }
DeclarativeRouteRegistration. RegisterRoutes()static method from the application instance class for your web application (Global.asax / Global.asax.cs), in order to properly configure the ASP.NET runtime and setup the SEO routing model.
RegisterRoutes()method, before any other eventual routes definitions; SEO routes can coexist with other, non-SEO routes: just consider that the ASP.NET engine will process routes according to the order of their definitions.
DeclarativeRouteRegistration. RuntimeLicenseKeystatic property equals to the value available in the Clients area.
public class MyApplication : System.Web.HttpApplication { // ... public static void RegisterRoutes(RouteCollection routes) { // SEO routing model registration DeclarativeRouteRegistration.RegisterRoutes(); // Standard ASP.NET routes routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } // ... protected void Application_Start() { // Setup the runtime license key for Cobisi SEO Extensions DeclarativeRouteRegistration.RuntimeLicenseKey = "..."; // ... RegisterRoutes(RouteTable.Routes); // ... } // ... }
Routeattribute, Cobisi SEO Extensions shows a visual feedback directly in the IDE, in order to highlight the search-engine optimized route you have defined.