Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

dealing session

Posted on 2006-07-11
6
Medium Priority
?
155 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

636 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