我在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事件?
答案 0 :(得分:30)
您可以将此添加到您的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
干杯!