asp.net-mvc-4 – MVC4如何挂钩OnSessionStart事件?

前端之家收集整理的这篇文章主要介绍了asp.net-mvc-4 – MVC4如何挂钩OnSessionStart事件?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在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

干杯!

原文链接:https://www.f2er.com/aspnet/250445.html

猜你在找的asp.Net相关文章