Click here to Skip to main content
15,914,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, i use Login control for login and when i run it from my local pc it works fine ,but when i host it then it can't go on my home.aspx page...
my login code
C#
SqlParameter[] paramater = new SqlParameter[]
            {
                new SqlParameter("@User_Name",Login1.UserName),
                new SqlParameter("@Password",Login1.Password)
            };
          SqlDataReader dr = (SqlDataReader)db.ExecuteReader("Login", paramater);
          if (dr.HasRows)
          {
              dr.Read();
              Session["Branch"] = dr["Branch"].ToString();
              Session["user"] = dr["Id"].ToString();
              dr.Close();
              DropDownList ddyear = (DropDownList)Login1.FindControl("ddyear");
              Session["year"] = ddyear.SelectedItem.Text;
              FormsAuthentication.RedirectFromLoginPage(Login1.UserName, Login1.RememberMeSet);
          }


in web.config
C#
<authentication mode="Forms">
     <forms defaultUrl="Home.aspx" loginUrl="LogIn.aspx" timeout="60"></forms>
   </authentication>
Posted
Comments
Kornfeld Eliyahu Peter 9-Jun-14 6:15am    
Do you have an error? Or it goes somewhere else?
dhiraj mane 9-Jun-14 6:17am    
No, i dont get any error, when i click on login it came back to login
dhiraj mane 9-Jun-14 7:19am    
i use
if (!this.Page.User.Identity.IsAuthenticated)
{
FormsAuthentication.RedirectToLoginPage();
}
that code in my master page
Kornfeld Eliyahu Peter 10-Jun-14 2:51am    
Maybe user never got authenticated? Please check it with debugger...

1 solution

use "~" with URL and increase the timeout as following:
HTML
<authentication mode="Forms">
      <forms defaultUrl="~/Home.aspx" loginUrl="~/LogIn.aspx" timeout="2000"></forms>
    </authentication>


please try it.
 
Share this answer
 
v2

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