You must Sign In to post a response.
  • Category: ASP.Net MVC

    About the mvc for a basic concept

    what is the exact use of Global.asax in asp.net mvc?
  • #766353
    Hi,
    Global.asax is a file which contains code for handling application level events. It resides in the root directory of an application.
    <ul><li>As far as ASP.NET MVC application is considered, you can use Global.asax file for 'ASP.NET routing' i.e. map incoming requests from browser to specific MVC controller actions.
    Please find a sample code for this:
    http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs
    </li>
    <li>Also for application level error handling. Please find a code for this over here:
    http://stackoverflow.com/questions/16884074/asp-net-mvc-application-error-handler-in-global-asax
    </li></ul>

  • #766357
    Hi,

    Global.asax file is used to Handle application level activities like error handling application start and end as well as session start and end everything we can handle in global.asax file.

    This is the file loading first while execute the application, and initialize Application level components, in a single project you can have only one global.asax file.

    If you want to know more about global.asax then refer below link

    http://www.asp.net/mvc/overview/older-versions-1/controllers-and-routing/asp-net-mvc-routing-overview-cs

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #766365
    The Global.asax file, also known as the global application file, it is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. The Global.asax file resides in the root directory of base application.
    MVC framework maps browser requests to controller actions and for that global.asax is important, here routes are defined in the Global.asax.cs file in a method called RegisterRoutes(..).
    a route table is created in the application's Global.asax file. The Global.asax file is a special file that contains event handlers for ASP.NET application lifecycle events. The route table is created during the Application Start event.

    Thanks
    Koolprasd2003
    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]


  • Sign In to post your comments