Page_Load事件中加入
Server.Execute("check.aspx");
check.aspx内容:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["flag"] != "true" || Session["type"] != "teacher" || Session["name"] == null|| Session["id"]== null)
{
Response.Redirect("errow.aspx");
}
}
其他的窗体都是可以的,只有这一个永远报错
Server.Execute("check.aspx");
check.aspx内容:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["flag"] != "true" || Session["type"] != "teacher" || Session["name"] == null|| Session["id"]== null)
{
Response.Redirect("errow.aspx");
}
}
其他的窗体都是可以的,只有这一个永远报错
解决方案 »
- 鼠标滑过合并过的tr 后 tr合并后的行变色 但是未合并的就只有第一行变色 ???
- VS2005调试问题
- asp.net MVC单元测试HttpCountext为空,急,在线等,分不多,感谢帮忙
- 急!datagrid列添加数据,请大家快来帮帮忙
- 求asp.net视频教程 急急急
- 如何在IFRAME外的事件里(例如BUTTON 的ONCLICK)写代码刷新IFRAME里的页面
- 开放式并发问题
- 未将对象引用设置到对象的实例。如何解决?
- 菜鸟求救!!
- 如何才能实现这种效果,就是点击按钮后,整个网页都不能操作了(鼠标点到任何地方都不法操作,但可以看)
- 在页面上的按钮,为什么执行了javascript弹出对话框后还执行服务端脚本?
- 200分求 "asp.net数据库管理系统开发实例导航" 一书的光盘源代码!
if (Session["id"]==null || Session["name"] == null || Session["flag"] != "true" || Session["type"] != "teacher" )
试试
Session是可能会丢失的
if (Session["name"] == null || Session["id"] == null || Session["flag"]==null || Session["type"]==null || Session["flag"].ToString()!= "true" || Session["type"].ToString() != "teacher" )
{
Response.Redirect("errow.aspx");
}
然后做了一个验证页面check.aspx
我在每页的page_load事件中加入server.excute("check.aspx")
其他的页面都可以实现验证权限功能
只有这一个,无论你是否是合法用户他都会跳到错误的页面(errow.aspx)
我做了十几页面
然后做了一个验证页面check.aspx
我在每页的page_load事件中加入server.excute("check.aspx")
其他的页面都可以实现验证权限功能
只有这一个,无论你是否是合法用户他都会跳到错误的页面(errow.aspx)你说的这种用法我以前也做过...
但是你没有把错误说清楚,所以别人也没法帮你啊...
还是Session["flag"]="true"?等等..
如果他成立就重定向到登陆页面
否则就进入此页面
奇怪的是无论条件是true or false 永远进入的都是true 的页面
调试一下!
{
if (!IsPostBack)
{
//Server.Execute("check.aspx");
this.palalter.Visible = true;
this.palinsert.Visible = false;
init();
}
}
public void init()
{
SqlConnection mycon = DB.myconnection();
mycon.Open();
SqlDataAdapter dp = new SqlDataAdapter("select * from cmtion", mycon);
DataSet ds = new DataSet();
dp.Fill(ds, "cmtion");
this.dg.DataSource = ds.Tables["cmtion"].DefaultView;
this.dg.DataBind();
mycon.Close();
}
改为:if(!(Session[flag"]==""true" && Session["type"] =="teacher"))
{
Response.Redirect("errow.aspx");
}
为什么要加入这么多的条件,最好是对不同的类型做出不同的处理。