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");

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?

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.

commented: good suggestion. +14


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