Solved

dealing session

Posted on 2006-07-11
6
147 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to count occurrences of each item in an array.

771 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

11 Experts available now in Live!

Get 1:1 Help Now