简体   繁体   中英

What is the source of Events in Global.asax?

Global.asax inherits HttpApplication class. But HttpApplication does not contain all the events of Global.asax. So where are the rest of events present? They must be inherited from somewhere. What is their source ?

They're not inherited from anywhere. They're hooked up by the Asp.Net pipeline via a convention

During the application life cycle, the application raises events that you can handle and calls particular methods that you can override. To handle application events or methods, you can create a file named Global.asax in the root directory of your application.

...

ASP.NET automatically binds application events to handlers in the Global.asax file using the naming convention Application _event

And, finally, this model is extensible:

If you add modules to your application, the modules themselves can raise events. The application can subscribe to in these events in the Global.asax file by using the convention modulename_eventname .

Which is why you can get eg Session related events in this file also, such as Session_Start .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM