小弟在global.asax文件中的Application_AcquireRequestState事件中写了如下的代码:protected void Application_AcquireRequestState(Object sender, EventArgs e)
{
if(Session["UserName"] == null || (string)Session["UserName"] =="")
Response.Redirect("default.aspx"); //未登陆返回首页
}结果连主页default.aspx都打不开了,也不报错,不知是为什么。请各位大哥指教下。
PS:这是小弟在csdn的处子贴,没有银子给大家。另外,如果在global.asax中写了事件代码,在cs文件中还要添加什么代码来引用这个事件?感恩涕零!
{
if(Session["UserName"] == null || (string)Session["UserName"] =="")
Response.Redirect("default.aspx"); //未登陆返回首页
}结果连主页default.aspx都打不开了,也不报错,不知是为什么。请各位大哥指教下。
PS:这是小弟在csdn的处子贴,没有银子给大家。另外,如果在global.asax中写了事件代码,在cs文件中还要添加什么代码来引用这个事件?感恩涕零!
Response.Redirect("default.aspx",false)这样好像也解决不了呀?
{
if(Session["UserName"] == null || (string)Session["UserName"] =="")
Response.Redirect("default.aspx"); }
{
if(!(HttpContext.Current.Request.Path=="default.aspx"))
{
if(Session["UserName"] == null || (string)Session["UserName"] =="")
Response.Redirect("default.aspx"); //未登陆返回首页
}
}
我这样写还是打不开那个 default.aspx 这个页面?
要是非要在global.asax里写,你可以这样写写看
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
Application.Lock();
Application["UserName"] = null;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
// 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
// InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。
Application.Lock();
Application["UserName"] = null;
Application.UnLock(); }
你最好全部TOUPPER()后判断是不是等于/DEFAULT.ASPX
为什么进度条走到一半 不走了?
为什么进度条走到一半 不走了?