在asp.net web中怎样在登录后自动转到登录前的页面并刷新

解决方案 »

  1.   

    你的意思是重新登陆吧?
    Server.Tranfer(Url)
    就可以
      

  2.   

    将已验证身份的用户重定向回最初请求的 URL:
    FormsAuthentication.RedirectFromLoginPage(string, bool);
      

  3.   

    我写的程序里面的一段
    private void LBtnlogin_Click(object sender, System.EventArgs e)
    {
    //这里不使用验证控件
    if(email.Text.Trim() == String.Empty || password.Text.Trim() == String.Empty)
    {
    Message.Text = "用户名或密码不能为空!";
    return;
    }
    //if(Page.IsValid)
    //{
    string hashedPassword = PortalSecurity.Encrypt(password.Text.Trim());
    String userInfo = null;
    //if(DDListLoginType.SelectedIndex != 1)//使用用户代码登录
    //{
    // userInfo = PortalSecurity.UserLoginWithUserCode(email.Text.Trim(),hashedPassword);
    //}
    //else
    //{
    userInfo = PortalSecurity.UserLoginWithUsername(email.Text.Trim(),hashedPassword);

    //}
    if ( userInfo != null && userInfo != "")
    {
    string userEmail = userInfo.Split('|')[1];
    if(Request.Url.ToString().ToLower().IndexOf("returnurl=") != -1)
    FormsAuthentication.RedirectFromLoginPage(userEmail,RememberCheckbox.Checked);
    else
    {
    FormsAuthentication.SetAuthCookie(userEmail, RememberCheckbox.Checked);
    //Response.Redirect(Request.ApplicationPath);
    Response.Redirect("~/Default.aspx");
    }
    }
    else //登录失败
    {
    Message.Text = "用户ID或密码错误";
    }
    //}
    }
      

  4.   

    你在所有点登录的地方,把连接地址用成(假设login.aspx是登录页,#####是当前页)
    http://..../login.aspx?u=#######然后登录完读取#####再跳回去不就结了么
      

  5.   

    其实只要记录原来的url,再跳转回去就可以了
    Uri MyUrl = Request.UrlReferrer;
    BackURL.Text = MyUrl.AbsoluteUri.ToString();
      

  6.   

    如果是用forms验证,可以用这个方法
    FormsAuthentication.RedirectFromLoginPage(string, bool);