在asp.net 中 如何在登录成功后2秒内自动跳转到登录前的页面 ,谢谢能不能给个实例.如登录页为login.aspx.前一个页为a.aspx我想和csdn一样.登录成功后.2秒自动跳转到a.aspx.当然a.aspx也是一个变量.是我获取的值.只用跳转就行了?

解决方案 »

  1.   


    response.rdirect(HttpContext.Current.Request.Url.PathAndQuery);
      

  2.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register_Succeed.aspx.cs" Inherits="Register_Succeed" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
        <link href="css/common.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
        #register_div
        {
            
        }
        #goto_div
        {
            height:40px;
            padding-top:30px;
            text-align:center;
        }
        </style>
        <script type="text/javascript">
        function goto_HomePage()
        {
            location.href = "default.aspx";
        }
        function time()
        {
            setTimeout(goto_HomePage,3000);
        }
        </script>
    </head>
    <body onload="time();">
        <form id="form1" runat="server">
        <!-- 顶部 -->
        <div class="top_div">
            
        </div>
        <!-- 中部 -->
        <div class="main_div">
            <div id="register_div">
                登陆成功
            </div>
            <div id="goto_div">
                <asp:Literal ID="Literal1" runat="server"></asp:Literal>,系统将在3秒后跳到 
                <a href="Default.aspx" title="赢在校园首页">赢在校园首页</a>
            </div>
        </div>
        
        <!-- 中部 -->
        <div class="bottom_div">
        
        </div>
        </form>
    </body>
    </html>
      

  3.   

    直接在html页面里加代码也可以
    <META http-equiv="Refresh" content="5;url=<%=url%>">
    5是等待的时间,url是要条状的页面
      

  4.   

    Response.Redirect(Request.UrlReferrer.ToString());
      

  5.   

     <script   language="javascript">   
      function   returnUrl()   
      {   
      window.location.href="Reg.aspx";   
      }   
      setInterval(returnUrl,2000);   
      </script>

    <script   language="javascript">   
      var   Sec=2;   
                      function   Start()   
                      {   
      Sec=Sec-1;   
      if(Sec==0)   
      { window.location.href="WebForm1.aspx";   
      }   
      else   
      {   
      document.Form1.elements["SecondTime"].value=Sec;   
      setTimeout("Start()",1000);   
      }   
      }   
      在body标记里添加   
      <body   onload="Start()"   MS_POSITIONING="GridLayout">   
      

  6.   

    直接在html页面里加代码也可以 
    <META http-equiv="Refresh" content="5;url= <%=url%>"> 
    5是等待的时间,url是要条状的页面或者用 js  window.location = "url";
      

  7.   

    不行呀.我的a.aspx也不随机的.并且我也不想再引入一个新页.最重要的是我想2秒后跳转