Where to write the code?

Posted by Laghaterohan under Regular Expressions on 3/8/2011 | Points: 10 | Views : 1515 | Status : [Member] | Replies : 9
Hi,

I want to redirect the user to the login page once the session has ended. This code should be included where?? In the Global.ascx under Session_End? OR Session_Start?

Presently , i have included it under Session_End but i think it is not working :(


Thanks!

Best Regards,
Rohan Laghate



Responses

Posted by: Madhu.b.rokkam on: 3/8/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Check this link

http://www.dotnetspider.com/forum/191565-How-redirect-login-page-from-Session-End.aspx

Thanks and Regards
Madhu

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 3/9/2011 [Member] Starter | Points: 25

Up
0
Down
But, the code mentioned on the above link...where to put it? Session_End ?


Thanks!


Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 3/9/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Laghaterohan
i think u use logout butun for kill ur session . . then u redirect the another page . .
why u using Global.ascx file . . .


Best Regard's
Prabhakar

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 3/9/2011 [Member] Starter | Points: 25

Up
0
Down
HI prabhakar,

Suppose, i open some page and its idle for say 30 mins... Now i click on some another menu of my application then in such case it gives me object reference error. I want to handle such kind of situation...

In the above mentioned scenario, i want that when the user clicks on menu item and if his/her session has ended then the user should be redirected to login.aspx so i am making use of Global.ascx..am i correct in doing so?

Also, is there any way in which i can redirect user Automatically to Login page after the session has ended??

Thanks!

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 3/9/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Laghaterohan .

i think u little bit confuse . . firstly u make two master page the one u will all menu ...without login .... then second master page u show after login . . and on second master page u show show only usable menu are displayed . with logout button . . on logout button u Kill session with Session.Abandon then u redirect the User Login Page . .
i think this the easy and gud way for u . .

Best Regard's
Prabhakar

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhuk on: 3/9/2011 [Member] Starter | Points: 25

Up
0
Down
Suppose, i open some page and its idle for say 30 mins... Now i click on some another menu of my application then in such case it gives me object reference error. I want to handle such kind of situation...

It is Global.asax and not Global.ascx.
You can redirect to login page if session expires in Session_Start event handler have a look at the link.
http://www.pragimtech.com/sessiontimeout.aspx

Also you can check for the session expired in the page load event of the page and redirect to your desired page.
If(Session["userID"]==null)

{
Response.Redirect("Login.aspx");
}


Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/9/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Check this link

http://www.dotnetfunda.com/codes/code1296-redirect-to-session-out-page-after-certain-interval-of-time.aspx

Thanks and Regards
Madhu

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhu.b.rokkam on: 3/9/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Note you cannot use Response.Redirect or Server.Transfer in the global.asax page so if you a master page add the code in the above link that will do the task for you.

Thanks and Regards
Madhu

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 3/10/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Login to post response