Click here to Skip to main content
16,021,004 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a master page file located in myproject/MasterPages
and my content pages are located in myproject/pages

The login page is located on myproject/default.aspx

I am applying the functionality that a user should have to login for viewing a page
i m doing this in masterpage's load event like this ==>

C#
protected void Page_Load(object sender, EventArgs e)
  {
      if (Session["user"] == "" && !SessionProperties.IsUser)
      {
          Response.Redirect("~/Default.aspx");
      }
      else
          Response.Redirect("~/Pages/Default.aspx");
  }




I want to know how can i Write First Response.Redirect so that it redirects user to Login page?
Posted
Updated 1-Feb-11 0:25am
v2

1 solution

write this code to the ~/Default.aspx page instance of the master page
protected void Page_Load(object sender, EventArgs e)
  {
      if (Session["user"] != null && SessionProperties.IsUser)
      Response.Redirect("~/Pages/Default.aspx");
  }

And write this code to the master pages of the secure pages
protected void Page_Load(object sender, EventArgs e)
  {
      if (Session["user"] == null || !SessionProperties.IsUser)
      {
          Response.Redirect("~/Default.aspx");
      }
  }
 
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