Amit Toren Amit Toren - 1 year ago 121
ASP.NET (C#) Question

Web api mvc configuration

I'm trying to figure out what the

is and what the lines in it mean.

I understood the concept of the global file but I can't seem to figure out what the content of it means. This is the file:

Protected void Application_Start()


Also, I understood there is an importance to the order of these lines.

Answer Source

This is essentially the MVC frameworks bootstrap method to hook into the ASP.NET framework on startup. The Application_Start gets called when the application domain is loaded. You can edit this file as you see fit and depending on what you chose when you created your now project some of these lines may or may not be included by default. What you have there.

  • AreaRegistration.RegisterAllAreas(); - registers the areas, if you have an mvc application you can configure areas which are ways to further group functionality / views. See Areas for more detail.
  • WebApiConfig.Register(GlobalConfiguration.Configuration); - registers the Web API routing and additionally add global web api filters.
  • FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); - Add global mvc filters. See also previous SO question what this method does.
  • RouteConfig.RegisterRoutes(RouteTable.Routes); - initialize the mvc routing.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download