Here is my code in global.asax:
- protected void Application_Start()
- {
- AreaRegistration.RegisterAllAreas();
- WebApiConfig.Register(GlobalConfiguration.Configuration);
- FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
- RouteConfig.RegisterRoutes(RouteTable.Routes);
- BundleConfig.RegisterBundles(BundleTable.Bundles);
- AuthConfig.RegisterAuth();
- }
- //void Session_OnEnd()
- //{
- // RouteData routeData = new RouteData();
- // routeData.Values.Add("controller", "Home");
- // routeData.Values.Add("action", "logout");
- // //routeData.Values.Add("Summary", "Error");
- // //routeData.Values.Add("Description", ex.Message);
- // IController controller = new HomeController();
- // controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
- //}
- //protected void Session_Start(object src, EventArgs e)
- //{
- // if (Context.Session != null)
- // {
- // if (Context.Session.IsNewSession)
- // {
- // string sCookieHeader = Request.Headers["Cookie"];
- // if ((null != sCookieHeader) && (sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
- // {
- // // how to simulate it ???
- // // RedirectToAction(“ActionName”, “ControllerName”, route values);
- // Response.Redirect("/Home/logout");
- // }
- // }
- // }
- //}
- void Session_OnEnd(object sender, EventArgs e)
- {
- //if (Session.IsNewSession)
- //Response.RedirectToRoute("logout", "Home");
- //RouteData routeData = new RouteData();
- //routeData.Values.Add("controller", "Home");
- //routeData.Values.Add("action", "logout");
- ////routeData.Values.Add("Summary", "Error");
- ////routeData.Values.Add("Description", ex.Message);
- //IController controller = new HomeController();
- //controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
- // HttpContext.Current.RewritePath("Home/logout");
- //Response.Redirect("~/Home/logout");
- //HttpContext.Current.Response.Redirect("~/Home/logout");
- }
i want to redirect when session end occurs after some time(1 minutes).
this is my
- web.config(
"InProc" timeout="1" />)
i have tried a lot of code..but not working.
when the Session_OnEnd occurs i want to redirect to Home controller.but the above code in Session_OnEnd not working any suggestion.
the error occurs in Session_OnEnd is:
- : An exception of type 'System.NullReferenceException' occurred in MyZefer.UI.dll but was not handled in user code Additional information: Object reference not set to an instance of an object. Object reference not set to an instance of an object.
any suggestion??
how to redirect to controller???

Manoj MaharanaRank #4,500 · 340 reputationPosted Jan 6, 2017, 12:36 AM EST
Manas MohapatraRank #182 · 13.2K reputationPosted Jan 6, 2017, 12:09 AM EST