Controllers In MVC By Sagar Jaybhay
In this article you will understand what Is Controllers In MVC and What is the use of Controller in Asp.Net MVC. Controllers In MVC In MVC the URLs are mapped to the Controllers action method so the question is how URLs are mapped to the Controllers action method? The answer for that ASP.NET routing. It is registering in Global.asax file. Gloabl.asax File In MVC The Registeroute method Is present in RouteConfig.cs file see below image, RegisterRoute Method In MVC Below is the RegisterRoute method in that class file. public static void RegisterRoutes(RouteCollection routes) routes.IgnoreRoute("resource.axd/*pathInfo"); routes.MapRoute( name: "Default", url: "controller/action/id", defaults: new controller = "Home", action = "Index", id = UrlParameter.Optional ); } In the above code, you can see, the Default route is present it means if you simply run the application then it will invoke this URL path the normal path whic