我在page_load事件里写的
if (Session["name"] == null)
{
Response.Redirect("login.aspx");
}
在运行程序的时候能成功跳转至登录界面。但是直接输入网址打开。却不会跳至登录界面。怎么回事?
直接打开的本地网址是http://localhost:9327/XXXXX.aspx
我觉得是因为本地网址直接打开了后没做pageload里的判断。
怎么才能防止直接本地网址打开?
if (Session["name"] == null)
{
Response.Redirect("login.aspx");
}
在运行程序的时候能成功跳转至登录界面。但是直接输入网址打开。却不会跳至登录界面。怎么回事?
直接打开的本地网址是http://localhost:9327/XXXXX.aspx
我觉得是因为本地网址直接打开了后没做pageload里的判断。
怎么才能防止直接本地网址打开?
if(!ispostback)
{
if (Session["name"] == null)
{
Response.Redirect("login.aspx");
}
}
{
//if (Session["name"] == null)
//{
// Response.Redirect("login.aspx");
//} if (Session["name"] == null)
{
Response.Redirect("login.aspx");
} }
把浏览器关掉再登陆试试看?!