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

B

Billy Zhang

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
 
B

bruce barker

this is what the global.asax is for. PostAcquireRequestState would be a
good event.

-- bruce (sqlwork.com)
 
S

Steven Cheng

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: (e-mail address removed).

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

http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top