Solved

Alternative to Response.Redirect on session end

Posted on 2011-03-03
8
1,070 Views
Last Modified: 2012-06-27
Hi all,

I have the following code in a global.asax file:

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
    Response.Redirect("~/Relogin.htm")
End Sub


The problem is that when the session ends, the Response object seems to be null and so I am getting an error.

Does anyone have an alternative to this or is it possible to create a new response object.

Thanks.

resourcesys.
0
Comment
Question by:resourcesys
  • 3
  • 3
  • 2
8 Comments
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35025471
Session_End is fired internally by the server, based on an internal timer. Thus, there is no HttpRequest associted when that happens. That is why Response.Redirect or Server.Transferdoes not make sense and will not work.
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35025502
Use forms authentication

<authentication mode="Forms">
        <forms name=".Login" loginUrl="LoginPage.aspx"
            protection="All" path="/" timeout="5" />
    </authentication>
.....

<sessionState mode="InProc" ... timeout="5"/>

this way whenever the session expires the form authentication too times out and when the user clicks on anything he will be redirected to login page..
0
 
LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 35025507
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 14

Expert Comment

by:Dhanasekaran Sengodan
ID: 35025519
0
 

Author Comment

by:resourcesys
ID: 35025685
Cannot use forms authentication.

Has to be from within the session end method.
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 35025736
0
 

Accepted Solution

by:
resourcesys earned 0 total points
ID: 35187741
Thanks to everyone, unfortunately issue is still there.
0
 

Author Closing Comment

by:resourcesys
ID: 35225128
No acceptable solution provided
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

823 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question