Global.asax.cs 中的 Session_Start 和 Session_End

A.B*_*.B. 1 .net c# asp.net-mvc

这两个事件处理程序属于哪个类的哪个事件?

例如的Application_BeginRequestGlobal.asax中被命名约定注册的BeginRequest类的HttpApplication。

我在这 3 个类中找不到关于这 2 个会话事件的任何内容: HttpApplicationHttpContextHttpSessionState

Dam*_*ver 5

他们属于SessionStateModule.

这是旧文档,但如果您从使用具有 Global.asax 文件的模块开始,您将看到您可以订阅的事件由实现IHttpModule接口的类型公开。查看该接口的文档,您会发现实现的内置类型IHttpModule

Class                         Description
DefaultAuthenticationModule   Insures that an Authentication object is present in the context. This class cannot be inherited.
FileAuthorizationModule       Verifies that the remote user has NT permissions to access the file requested. This class cannot be inherited.
FormsAuthenticationModule     Enables ASP.NET applications to use forms authentication. This class cannot be inherited.
PassportAuthenticationModul   Provides a wrapper around PassportAuthentication services. This class cannot be inherited.
SessionStateModule            Provides session-state services for an application.
UrlAuthorizationModule        Provides URL-based authorization services for allowing or denying access to specified resources. This class cannot be inherited.
WindowsAuthenticationModule   Enables ASP.NET applications to use Windows/IIS authentication. This class cannot be inherited.
Run Code Online (Sandbox Code Playgroud)