473,773 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Beg inRequest(Objec t 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 2297
Try this:

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

Response.Redire ct("redirectpag e.aspx");

}

"francois" <fr******@betti nghouses.com_NO SPAM> wrote in message
news:Of******** *****@TK2MSFTNG P09.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_Beg inRequest(Objec t 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_Beg inRequest(Objec t 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.Http Exception: Session state is not available
in this context.

Line 55: protected void Application_Beg inRequest(Objec t 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****@trilium software.com> wrote in message
news:eS******** ******@TK2MSFTN GP12.phx.gbl...
Try this:

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

Response.Redire ct("redirectpag e.aspx");

}

"francois" <fr******@betti nghouses.com_NO SPAM> wrote in message
news:Of******** *****@TK2MSFTNG P09.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_Beg inRequest(Objec t 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
43197
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
7847
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 to the page after timeout occurs. Any suggestions? Thanks in advance ....
2
5489
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
7311
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 (without entering username and password) using the cookies. Now in this case the 20 mins session timeout has no meaning anymore so I m thinking to make the timeout infinite in this case only. my question is, if i do this, and then a user used the...
3
9564
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 loaded into the IFRAME, where can that error condition be trapped? Thanks Timo
1
3597
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 the login page. OK., Im aware that we have 2 timeouts. Session timeout and forms authentication timeout. In login i do this
4
9457
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 the forms authentication to be a large value for that page also. TIA - Jeff.
20
3781
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 information will be lost. I've tried doing a Reponse.Redirect call back to my login page whenever I detected the Session is null, but I kept getting the exception saying "... Redirect not all in Page Callback".
4
8143
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 with the continued timeout we sometimes experience. I have tried just about everything to allow an 8 hour timeout for this application. I've set the session timeout to 480 in IIS (running IIS 6 on windows 2k3 SE) and i've also tried coding it in...
3
2732
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 doing other things will a page of mine is up on the screen. But the session times out so that when I try and use a session variable, it crashes saying Object reference not set to an instance of an object. So I put <sessionState timeout="4800" />
0
9621
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6717
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.