C#、.NET中如何在Global.asax中实现页面跳转,急急急

C#、.NET中如何在Global.asax中实现页面跳转?用于定时器,每隔一段时间就跳转

  protected void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            System.Timers.Timer myTimer = new System.Timers.Timer(60000);//一分钟
            myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
            myTimer.Interval = 60000;
            myTimer.Enabled = true;
        }
 //你要定时执行的代码放这里 
         void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
        {
            在这里实现地址跳转,但是如何跳转???????
        }

timeout????

在Session_End方法中代码:

protected void Session_End(object sender, EventArgs e)
{ // 在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为 InProc 时,才会引发 Session_End 事件。
// 如果会话模式设置为 StateServer
// 或 SQLServer,则不会引发该事件。

                Response.Write("<script>alert('您还没有登陆或者登陆已超时');parent.window.location.href='Login.aspx'</script>");


    }

设置定时器间隔时间就行了

protected void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
System.Timers.Timer myTimer = new System.Timers.Timer(60000);//一分钟
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(OnTimedEvent);
myTimer.Interval = 60000;
myTimer.Enabled = true;
}
//你要定时执行的代码放这里
void OnTimedEvent(object source, System.Timers.ElapsedEventArgs e)
{
在这里实现地址跳转,但是如何跳转???????
}

Application_BeginRequest判断下你的时间,满足需求Response.Redirect转向就行了,还得注意判断不是转向的url地址,要不就死循环了


    void Application_BeginRequest(object sender, EventArgs e)
    {
        if (/*这里加上时间判断*/Request.Url.AbsolutePath != "/xxx/xxx.aspx")
        {
            Response.Redirect("/xxx/xxx.aspx");
            Response.End();
        }
    }