我在VS2010中启动了MVC4项目,
在Global.asax.cs中,例如:

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        AuthConfig.RegisterAuth();
    }
}


如何注册Session Start事件?

最佳答案

您可以像这样将其添加到您的Global.asax.cs中:

protected void Session_Start(object sender, EventArgs e)
{
    // event is raised each time a new session is created
}

protected void Session_End(object sender, EventArgs e)
{
    // event is raised when a session is abandoned or expires
}


您可能还应该检查
http://msdn.microsoft.com/en-us/library/bb470252(v=vs.100).aspx

干杯!

关于asp.net-mvc-4 - MVC4如何 Hook OnSessionStart事件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18954830/

10-10 19:02