When session expires redirect the page to login screen

Hi Experts,

I want to redirect the page to the login screen if the application is open and not used for certain amount of time. I am using
<sessionState timeout="60" cookieless="UseCookies" mode="InProc"/> to set the session time out. I am using ASP.Net and VB.Net. Please help.

Thanks.
RadhaKrishnaKiJayaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
I presume you already have code behind to see if there is a session at all, and if not, redirect the user to the login screen.  If that's the case, the easiest thing to do would be to put a meta tag in the header of your that causes the page to refresh:

<META HTTP-EQUIV="refresh" CONTENT="Amount_Of_Time_In_Seconds_Before_Refresh">

When the page refreshes, you'll catch the expired session and redirect to the login page.  A value of 3660 would give you 61 minutes.
0
Prakash SamariyaIT ProfessionalCommented:
From code behind, add redirect to login page after expires
Add below line in Page_Init event
Response.AppendHeader("Refresh", "60; URL=login.htm")

Open in new window

0
RadhaKrishnaKiJayaAuthor Commented:
Do I have to add it to each and every page?
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

Paul MacDonaldDirector, Information SystemsCommented:
Yes, but you should be doing something like this anyway.  Do you not check for a logged-in session on every page that requires it?  Do you not use a Master Page or include file store items common to all your pages?
0
RadhaKrishnaKiJayaAuthor Commented:
Thank you very much for ur reply.
I am doing this on every page. But I am not sure if this is the right way to do this.

 If Session("Role") Is Nothing Then
            Response.Redirect("Login.aspx")
  End If
0
Paul MacDonaldDirector, Information SystemsCommented:
That looks good to me.  Combine that with the META REFRESH and I think you'll be all set.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RadhaKrishnaKiJayaAuthor Commented:
Thank you very much.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.