Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using C#,asp.net,VS 2005 and sql server 2005

My problem is:When user type the url without login ,how i can redirect the user to login page?

Is it Using session? How to do that?

thanks in advance.
with regards
karan
Posted

when u r logging that time u assign username or any thing that u can check to session, then on every page u check this session if it is null then u redirect it to login page
 
Share this answer
 
Comments
karan joshua 16-Jun-11 9:03am    
oh k.thank u. i had same idea... Is it (sesssion)giving problem if many user is accessing simultaneously.?
amit28august 16-Jun-11 9:11am    
no the browser creates a different session for every session start event.
karan joshua 16-Jun-11 9:13am    
should i check it in page_load event?
amit28august 16-Jun-11 9:15am    
ya in the page load event of each page
amit28august 16-Jun-11 9:16am    
if (Session["ssnLoginName"] != null)
{
intLoginID = int.Parse(Session["ssnLoginID"].ToString());
wlblLoginName.Text = Session["ssnLoginName"].ToString();
}
else
{
Response.Redirect("../Loginweb.aspx");
}
 
Share this answer
 
v2
try to use security concept like


'FormsAuthentication'


if U use this ur site will get much more security


without providing user credential when user try to access the page of the app

it will redirects the user to login page


not only this ur site will get better security restricting unauthorised access
 
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