Click here to Skip to main content
15,905,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an serious Problem when i am Copying the Url in another webPage that Specific Page is opening..
Its not checking the Sessions in the new Web Pages..
I want to avoid such Things in my Web Pages

Kindly Help Me

Thanking you
Sushil Dharmar
Posted

If you have to check for some session variable in all the pages then perhaps you can do this in AcquireRequestState event in global.asax file. here you can check if the session variable exist or not, if not then you can push the user to a the default page.
C#
void Application_AcquireRequestState(object sender, EventArgs e)
{
  //Session is Available here
  HttpContext context = HttpContext.Current;
  if(context.session["value"] == null)
  {
    //redirect to default page
  }
}

Also, You need to check that when is this session variable that you are using is getting killed. chances are that it might not be getting killed and thus simply copying the URL is opening the page.
 
Share this answer
 
Comments
AshishChaudha 16-Aug-12 23:55pm    
my +5!
Abdul Quader Mamun 17-Aug-12 1:16am    
good Answer!
Ganesh Nikam 17-Aug-12 3:44am    
good answer
SushilDharmar 17-Aug-12 11:31am    
I Don't Know how to thank you all
Thank you Friends you had Saved my code a lot...!!
Manas Bhardwaj 21-Aug-12 9:16am    
5ed !
Hi Sushil,

You need to take advantage of the OOPS techniques. Do one thing create a class that derives from system.web.ui.page and write a virtual implementation of Page Init method that checks whether the session variable is set or not. If it is not set then redirect to the login page.

Now in your asp.net pages remove the ": system.web.ui.page" after the page class, you will just need to inherit the newly created class that has inherited page class.

Regards
Pawan
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900