if (Session["username"] != null)
{
Response.Redirect("Login.aspx");
}
1 个答案:
答案 0 :(得分:0)
您必须在“ Login.aspx.cs”文件的Page_Load方法中编写这段代码。
带有方法的代码将是这样
protected void Page_Load(object sender, EventArgs e)
{
if (Session["username"] != null) // Checks if username is available in session
{
Response.Redirect("Homepage.aspx"); // If user is logged in than redirect to Homepage.aspx
}
}