1,105,332 Community Members

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

Member Avatar
shahai.ali
Light Poster
48 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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?

Member Avatar
JorgeM
IT Addict
6,387 posts since Dec 2011
Reputation Points: 567 [?]
Q&As Helped to Solve: 956 [?]
Skill Endorsements: 172 [?]
Moderator
Featured
Sponsor
 
1
 

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

Member Avatar
manuindia
Newbie Poster
2 posts since Dec 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

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
        }
    }   
Question Answered as of 1 Year Ago by JorgeM and manuindia
Member Avatar
shahai.ali
Light Poster
48 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

thnx

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: