O'Reilly logo

ASP.NET MVC 1.0 Quickly by Maarten Balliauw

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Defining routes

Routes are defined on application startup, which is typically triggered by the Application_Start event in the Global.asax file. This event is called when the web application is first started. Make sure that you register all of the routes in a separate, static method. This will enable you to write unit tests more easily. Note that the first matching route pattern will always be used. Here's an example of a Global.asax file:

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Routing; namespace MvcApplication1 { public class GlobalApplication : System.Web.HttpApplication { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required