1

I need to redirect the user to the login page on session timeout. The issues with Session_End method in the global.asax are:

  1. It does not support Response.Redirect or Server.Transfer
  2. Any attempt to use HttpContext.Current.Response results in 'Object Reference not set to an instance of an object' error
The second error is understandable since on session time out, the current session would be terminated and set to null.
What I want to know is whether is it possible to redirect the user directly (and specifically) from session_end to another page. There are methods which work (not using the session_end method), but all of them require a request to the server(such as a refresh,which I don't want). Can i do this without using javascript?(more important, should I?)
Thanks in advance!
Shubhang
  • 297
  • 1
  • 5
  • 13

1 Answers1

1

Isn't Session_End raised directly on server, without any interaction from user?

What happens, when I go to your page (and start a session), close browser window and never return? Then it's understandable, that HttpContext.Current.Response is null.

Axarydax
  • 16,353
  • 21
  • 92
  • 151
  • Yes,it is raised on the server directly. The solutions which I mention work are not implemented using Session_end.I should have stated that too. In response to your second query, the application restarts over again on doing that. – Shubhang Apr 01 '13 at 08:29
  • 1
    Then maybe I would hack around the issue by using a long timer in client-side script, for example if your session timeout is 20 minutes, I would schedule event in client script 20 minutes from now to refresh the page, which should lead to login page. – Axarydax Apr 01 '13 at 11:58