We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,621 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how to not allow a person to access the page without login??

hi m new to asp.net and m trying to secure my pages so that if the user is not logged the pages are not accessed to him.
previously i have done in php like in the following:

if(!isset($_SESSION['adminlogin']) || $_SESSION['adminlogin'] == ''){
    header("Location: index.php");
    exit;
}

but i don't know how to prevent users from accessing the pages with out login in asp.net anybody is there to help me?

3
Contributors
3
Replies
5 Days
Discussion Span
5 Months Ago
Last Updated
4
Views
Question
Answered
shahai.ali
Light Poster
48 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

You could implement security manually in the manner you are describing above, but there is a another approach using built in classes, methods, etc... I would suggest you start looking at Security documentation on the asp.net website.
http://www.asp.net/web-forms/tutorials/security

JorgeM
Senior Poster
3,996 posts since Dec 2011
Reputation Points: 294
Solved Threads: 543
Skill Endorsements: 115

hii,

you can check session in pageload event in perticular page not allow to access the page.

eg. Home.aspx

protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["adminlogin"] == null)//Sessioon Check
        {
            Response.Redirect("~/Login.aspx");//Redirect to your Login Page
        }
    }   
manuindia
Newbie Poster
2 posts since Dec 2012
Reputation Points: 0
Solved Threads: 1
Skill Endorsements: 0
Question Answered as of 5 Months Ago by JorgeM and manuindia

thnx

shahai.ali
Light Poster
48 posts since Aug 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0633 seconds using 2.69MB