Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing code for log in functionality. I am able to login successfully but my problem is, when i directly call that adminhome.aspx page by url that is accessible directly.I want that should navigate to login page if someone is trying to directly access adminhome.aspx. I am using session variable for user LoginId.

Thanks & Regards
Nitin Kumar
Posted
Updated 30-Oct-12 21:11pm
v2

In page load event of
adminhome.aspx
page write below code.
Make sure you have Abandoned session when uesr logout.

C#
if (Session["session_var"] == null || Convert.ToString(Session["session_var"]) == "")
{
           Response.Redirect("~/adminhome.aspx");
}
 
Share this answer
 
v2
I am assuming that you are writing your own login system? If so, then providing such security is up to you, and it is a complicated thing, or requires you to explicitly check the authorisation in every single page load event.

The easy solution is to implement Membership: MSDN - Introduction to Membership[^] which lets the framework take the difficulty and allows you to set access levels by folder very easily.
 
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