O'Reilly logo

Learning Angular for .NET Developers by Rajesh Gunasundaram

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

Routing for ASP.NET MVC

We just created an ASP.NET MVC controller and added a view for an Index action in the controller. Now we need to configure routing for the ASP.NET MVC application so that any request to the Index action is handled by the ASP.NET MVC router. Follow these steps to configure ASP.NET MVC routing:

  1. Open Startup.cs.
  2. Comment or remove the app.UseDefaultFiles() statement from the Configure method as we will serve views using ASP.NET MVC.
  3. Replace the app.UseMvc() statement in the Configure method with this one:
     app.UseMvc(config =>   
            {   
              config.MapRoute(   
              name: "Default",   
              template: "{controller}/{action}/{id?}",   
     defaults: new   { controller = "Home", action =         "Index" }   
               );   
            });

Here, we have added the default routing for ASP.NET ...

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