Solved

dealing session

Posted on 2006-07-11
6
148 Views
Last Modified: 2010-04-06
In ASP.NET 2.0 with C# I want that whenever there is a session timeout or the user pressed for signout
to link to a starting page of login.
Is it OK to do the following?
In global.asax in Session_end event to write:
 
void Session_End(object sender, EventArgs e)
    {
         Session_Start(sender, e);
     }

and in Session_Start to call the page of login

void Session_Start(object sender, EventArgs e)
    {
         string linkurl = "loginappl.aspx";
         Server.Transfer(linkurl, true);
     }

How do I handle pages that were left open and the session has timeout?
thankyou
Anat
0
Comment
Question by:ANAT2403
  • 2
6 Comments
 
LVL 15

Expert Comment

by:deepaknet
ID: 17088218
Anat,

Session_OnEnd is kind of non deterministic call. Check out this article for details and workaround: www.eggheadcafe.com/articles/20030416.asp

For your specific problem of restarting a fresh session, instead you can try maintaining the same session by sending a AJAX request to a page called 'LoginAppl.aspx?sess=restart" You save a lot of server resources.
0
 

Author Comment

by:ANAT2403
ID: 17088377
Hi,
Let me explain exactly what are my aim:
I want that when ever there is a session time out or the user pressed on a button of signout -
to have the first screen of login which will force the user to enter his password before he can proceed.
I also want to control that if the user got the login screen and pressed on the back page he will not be able
to do anything and get the login page again.
I want to imitate the web outlook access that pages are left and you made sign out.
I am not dealing at the moment with multiple users and I don't want to use the ajax.
What I wrote is working O.K. but I want to be sure that there is no problem with it and I am willing to learn about other ways.
Thank You
Anat
0
 
LVL 7

Expert Comment

by:skvikram
ID: 17129972
Create a web.config file as below and place it in application root. This will deny access to every user and redirects them to login.aspx

<configuration>
  <system.web>
    <authentication mode="Forms" />
  </system.web>

  <location allowOverride="false" path="\">
  <system.web>
    <authorization>
      <deny users="*" />
    </authorization>
  </system.web>
  </location>
</configuration>
0
 
LVL 7

Accepted Solution

by:
skvikram earned 500 total points
ID: 17130169
one more solution:
Create a global.asax file and place it in root directory of ur application

<Script Runat="Server">

Sub Session_Start
  If Instr( Request.Path.ToLower, "/login.aspx" ) = 0 Then
    Response.Redirect( "login.aspx" )
  End If
End Sub

</Script>
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now