Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi,

When i pass URL like : www.abcd.com/Admin

It should redirect as : www.abcd.com/Login.aspx

How can i get it, please help..
Posted
Updated 4-Sep-13 20:08pm
v2
Comments
Thanks7872 5-Sep-13 2:13am    
Why?

The best way is to implement Membership: http://msdn.microsoft.com/en-us/library/yh26yfzy.aspx[^]
If you do this, it becomes trivial and the system will handle all such things for you.
 
Share this answer
 
Comments
Dholakiya Ankit 5-Sep-13 3:15am    
want to know more about this
OriginalGriff 5-Sep-13 3:43am    
Then follow the link and get reading - it guides you through the process.
Dholakiya Ankit 5-Sep-13 4:16am    
ok asking you more once i read
method 1 :use membership
Understanding ASP.NET Roles and Membership - A Beginner's Tutorial[^]

Method 2:Use the session variable
Use the session variable in the page_load:

protected void Page_Load(object sender, EventArgs e)
{
    Session["loggedin"] = "false";
}
... and check the login event. If user has pressed the login button then set the session variable "true".

protected void btnOK_Click(object sender, EventArgs e)
{
    Session["loggedin"] = "true";
    ......
   ......
}
When the page is redirected to another page then check the status of the session variable in page load event.

    try
    {

        if (Session["loggedin"].ToString() == "false")
        {
            Response.Write("<script> alert('Session Expires! please login first'); </script>");

            Response.Redirect("login.aspx");
            return;
        }

    }
    catch (Exception er)
    {
        Response.Redirect("login.aspx");
    }



Happy Coding :)
 
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