Tell me about the difference between global.asax and global.asax.cs ?
and
If i click the both file in my solution explorer , it's goes to only server (asax.cs) side ,Why and how ? and can i see client side(global.asax) page ?
Global. asax is the asp.net application file. It is an optional file that handles events raised by ASP.NET or by HttpModules. Mostly used for application and session start/end events and for global error handling.
Global. asax contains code which is executed. Web. config contains configuration settings of web application, for example connection string, included libraries, namespaces, users and groups access permissions to virtual directories, etc.
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. The file in Listing 1 contains the default Global. asax file for an ASP.NET MVC application.
Global. ASP.NET Core introduced a new mechanism for bootstrapping an app. The entry point for ASP.NET applications is the Global. asax file. Tasks such as route configuration and filter and area registrations are handled in the Global. asax file.
Global.asax is the markup file that goes with the "code-behind" file .asax.cs. But the markup file isn't used for much, as far as I know (all the content normally goes into the code-behind file). You can view it, though, by right-clicking on it in Solution Explorer, and then "view markup".
You can't add content to the markup, only a few attributes:
<%@ Application Codebehind="Global.asax.cs"
Inherits="WebApplication1.Global"
Language="C#" %>
The MSDN docs seem to confirm that the only purpose of global.asax is to add/override handlers for application-level events:
The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules.
You can hit F7 when in codebehind file to display .asax
markup.
The global.asax
behaves somewhat like an aspx file, being compiled when the application starts.
You can even put your methods (like Application_Start
) in a script runat="server"
element in the global.asax.
I doubt it is good practice, but this should allow to hot-edit a running application (which should trigger a recycle I guess) It will then be compiled dynamically.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With