473,412 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

redirect to logon page after session timeout

Hi,

I would like to redirect the user to the login page after the session time
out.

I tried to do a trick in the global.aspx.cs

protected void Application_BeginRequest(Object sender, EventArgs e)

{

object obj = Session["memberId"];

if (obj == null)

{

// do redirect

}

}

But it says that the Session object cannot be called in that context.

My goal is that I am trying to check at each request if the session object i
stored in my Session is still existing or not. If not, it means the session
is timed out and that i need to log in again and go back to the log in page.

Thanks for any help

Francois
Nov 18 '05 #1
2 2266
Try this:

if(Session["memberID"] == null)
{

Response.Redirect("redirectpage.aspx");

}

"francois" <fr******@bettinghouses.com_NOSPAM> wrote in message
news:Of*************@TK2MSFTNGP09.phx.gbl...
Hi,

I would like to redirect the user to the login page after the session time
out.

I tried to do a trick in the global.aspx.cs

protected void Application_BeginRequest(Object sender, EventArgs e)

{

object obj = Session["memberId"];

if (obj == null)

{

// do redirect

}

}

But it says that the Session object cannot be called in that context.

My goal is that I am trying to check at each request if the session object i stored in my Session is still existing or not. If not, it means the session is timed out and that i need to log in again and go back to the log in page.
Thanks for any help

Francois

Nov 18 '05 #2
the problem is that i cannot access the Session veriable in the
Application_BeginRequest(Object sender, EventArgs e) method.

When i run the project the Global.aspx does not compile and show an show
the following error

Exception Details: System.Web.HttpException: Session state is not available
in this context.

Line 55: protected void Application_BeginRequest(Object sender, EventArgs
e)
Line 56: {
Line 57: if(Session["memberID"] == null)
Line 58: {
Then where can u do this check if i cannot do it in that method?

francois

"Antoni Massó Mola" <am****@triliumsoftware.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
Try this:

if(Session["memberID"] == null)
{

Response.Redirect("redirectpage.aspx");

}

"francois" <fr******@bettinghouses.com_NOSPAM> wrote in message
news:Of*************@TK2MSFTNGP09.phx.gbl...
Hi,

I would like to redirect the user to the login page after the session time out.

I tried to do a trick in the global.aspx.cs

protected void Application_BeginRequest(Object sender, EventArgs e)

{

object obj = Session["memberId"];

if (obj == null)

{

// do redirect

}

}

But it says that the Session object cannot be called in that context.

My goal is that I am trying to check at each request if the session
object i
stored in my Session is still existing or not. If not, it means the

session
is timed out and that i need to log in again and go back to the log in

page.

Thanks for any help

Francois


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Geigho | last post by:
Setting session timeout in web.config file does not seem to have any effect. Any explanation or suggestion will be appreciated.
6
by: Weave | last post by:
I would like to redirect to a logout page after a session has timed out. I have placed a response.redirect "loggedoff.asp" in the Session_OnEnd subroutine in the global.asa, but it does not move...
2
by: francois | last post by:
in my web.config i have the following : <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
8
by: Joe Abou Jaoude | last post by:
hi, I have a web app with forms authentication and a timeout session of 20 mins for security reasons. I recently added a feature that allows users (if they want to) to automatically log in...
3
by: Timo | last post by:
In javascript code on MyPage.aspx, I set a hidden IFRAME's source url: myframe.location.href = 'someotherpage.aspx'; If the session has timed out, preventing someotherpage.aspx from being...
1
by: Anders Jacobsen | last post by:
Hey Im devloping an application in asp.net 1.1 SP2. I need to control timeout values for each user. Im having trouble to make it work. When the session timouts out I want to redirect the user to...
4
by: UJ | last post by:
I have a page where the user can upload a video file. As you can guess, this may take a while. Is there a way I can change the session timeout for just this one page? I would also want to change...
20
by: Simon Says | last post by:
Hi, I've a login page in which after authenticating it via the Oracle DB, I will stored the user information into the Session. However, when the Session timeout occurs, all of the user...
4
by: thig95 | last post by:
Hi, I've got a web application written in ASP class with VBScript. We have a home grown conctact management system for my company that our users stay active in throughout the day. My problem lies...
3
by: Mufasa | last post by:
Folks, I'm having problems with my session timeout. People using my website leave it just sitting there while they do other things. They have logged in ( using Forms Authentication ) and will be...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.