473,847 Members | 1,439 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When session is invalid, how to redirect user to the login page

I have a asp.net app. When session is invalid, how to redirect user to the
login page? I don't want to add the code to redirect user to the login page
into every page.

Thanks,
-Billy
Nov 11 '08 #1
3 3238
this is what the global.asax is for. PostAcquireRequ estState would be a
good event.

-- bruce (sqlwork.com)

Billy Zhang wrote:
I have a asp.net app. When session is invalid, how to redirect user to the
login page? I don't want to add the code to redirect user to the login page
into every page.

Thanks,
-Billy
Nov 11 '08 #2
Hi Billy,

Are you using custom forms authentication which is based on some
information stored in session? Anyway, if you do need a central place
where you can check session state and redirect request, you can consider
the approach Bruce introduced(use some global events ).

And instead of using global.asax, you can also write a custom httpmodule to
hook any of the global events in ASP.NET. Here are two kb articles
introduce this:

#INFO: ASP.NET HTTP Modules and HTTP Handlers Overview
http://support.microsoft.com/kb/307985

#How To Create an ASP.NET HTTP Module Using Visual C# .NET
http://support.microsoft.com/kb/307996

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: ms****@microsof t.com.

=============== =============== =============== =====
Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/en-us/subs...#notifications.

--------------------
>From: =?Utf-8?B?QmlsbHkgWmh hbmc=?= <ht****@noemail .noemail>
Subject: When session is invalid, how to redirect user to the login page
Date: Mon, 10 Nov 2008 19:04:00 -0800
>I have a asp.net app. When session is invalid, how to redirect user to
the
>login page? I don't want to add the code to redirect user to the login
page
>into every page.

Thanks,
-Billy
Nov 11 '08 #3
You may also consider using a base page. Basically, create a class
that inherits from System.Web.UI.P age and have all of your aspx pages
inherit from that class. You can than put your session check code in
there.

http://aspnet.4guysfromrolla.com/articles/041305-1.aspx

Nov 12 '08 #4

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

Similar topics

6
26918
by: deko | last post by:
I'm trying to create a very basic login page that will redirect a logged in user to a secure page. I set the session_start variable at the top of the login page, then redirect to securePage.php if the user enters the right credentials. The redirect works, but apparently $HTTP_SESSION_VARS is not getting set because I cannot view securePage.php. Am I setting $HTTP_SESSION_VARS correctly? My guess is I'm missing something elementary. ...
9
2412
by: Brian Burgess | last post by:
Hi all, Anyone know of any issues with setting the value of a Session object to the value of a submitted form item via 'Session("mySessionObj")=Request.Form("myFrmElem")' ? In my case the Session object gets set fine. But when the user links to another page, the value of the session object is EMPTY. thanks in advance..
3
2927
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working flawlessly for a couple of years under Windows 2000 server but now is very inconsistent following a recent upgrade to Windows server 2003. Following a login, the login info is passed to this asp page that checks an Access database for the user name and...
12
43203
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.
3
4575
by: Carpe Diem | last post by:
Hello I have an aspx page that loses Session("user") value after a few minutes even after I set <sessionState mode="InProc" cookieless="false" timeout="300"> in web.config and wrote function Session_Start() { Session.Timeout = 3000; } in global.asax
12
6998
by: ACaunter | last post by:
Hi all, I was wondering how i could write some code which would automatically open the Login Page once the session has expired? -- AdamPC@hotmail.com
2
2295
by: Hillary Hill | last post by:
I have a login page written in ASP. Once the user logs in to the system, by clicking the certain link they can navigate to the purchase module written in ASP.Net. In the purchase module the user can logout. Once the user logs out I am calling the Session.Abandon() and redirecting the user to the login page written in asp application. How to make sure the ASP part of the application abandons the session.
18
6889
by: Rippo | last post by:
Hi I am using role base forms authentication in asp.net and have come across a problem that I would like advice on. On a successful login a session variable is set to identify a user. This is all good as this session variable is used to retrieve data for that user etc. However if I restart the webserver then the users session is lost but the ticket is still active. Therefore the user is not redirected back to the login page.
3
4344
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
The majority of pages on our site need authentication (forms auth against the aspnetdb database). I created an '~/auth' folder with its own config file forcing authentication for any pages in the folder. The default.aspx sits in the root folder and just does a Response.Redirect to an ~/auth/home.aspx page. The config forces authentication, which is carried out by ~/pub/login.aspx which has a standard asp:login control. I set up the...
0
9892
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
10991
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
10653
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...
1
10718
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10347
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...
1
7888
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7061
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();...
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3168
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.