?
Solved

dealing session

Posted on 2006-07-11
6
Medium Priority
?
154 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

WordPress Tutorial 1: Installation & Setup

WordPress is a very popular option for running your web site and can be used to get your content online quickly for the world to see. This guide will walk you through installing the WordPress server software and the initial setup process.

Question has a verified solution.

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

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Suggested Courses

765 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