Web.Config Timeout Expired Redirect Custom Error Page

G

Guest

Hi,

I have searched the net and still no luck...

I just want to automatically have a page redirected to another page when the
timeout set in the config file expires.

I currently have:

<sessionState
mode="InProc"
stateConnectionString="tcpip=127.0.0.1:42424"
sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
cookieless="false"
timeout="20"
/>

and want my ASP.Net app to automatically detect that the timeout has expired
and redirect to another page.

Can anyone help?

Thanks in advance.
 
G

Guest

The ASP.NET session timeout is a passive not an active action. When a
session times out, the session information is removed from the web server
memory. Upon a new web request to the web application the code can determine
if the session has timed out and then redirect to another page. If you are
looking to have the browser automatically redirect the user to another page
without the user causing a form post to occur then you'll need to write some
javascript (look up the setTimeout function)
 
Joined
Feb 3, 2006
Messages
1
Reaction score
0
Using Application_Error

You can check for the timeout error by looking at the inner exception of an error when it comes in the Global.asax

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)

Dim err As Exception = Server.GetLastError
If Not err.InnerException Is Nothing Then
With err.InnerException.Message

' Checks for timeout errors
If .ToString.IndexOf("Timeout expired.") <> -1 Then
Server.Transfer("Error.aspx?error=timeout")
Exit Sub

End If
End With
End If
End Sub

This works but may not be the cleanest of solutions. Anyone know a better way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top