怎样在登录后自动转到登录前的页面并刷新 在asp.net web中怎样在登录后自动转到登录前的页面并刷新 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的意思是重新登陆吧?Server.Tranfer(Url)就可以 将已验证身份的用户重定向回最初请求的 URL:FormsAuthentication.RedirectFromLoginPage(string, bool); 我写的程序里面的一段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或密码错误"; } //} } 你在所有点登录的地方,把连接地址用成(假设login.aspx是登录页,#####是当前页)http://..../login.aspx?u=#######然后登录完读取#####再跳回去不就结了么 其实只要记录原来的url,再跳转回去就可以了Uri MyUrl = Request.UrlReferrer;BackURL.Text = MyUrl.AbsoluteUri.ToString(); 如果是用forms验证,可以用这个方法FormsAuthentication.RedirectFromLoginPage(string, bool); 求匹配的正则,搜索并替换 求免费不要备案的主机能够支持asp.net 4.0的 带数据库的winform发布运行不了~~~ masterpage子页面的动态控件获取 C#中PictureBox控件中获取鼠标相对图片位置的坐标 如何在别的线程中调用主窗口控件的属性 c#中chart控件如何画出曲线图 sql server 中的case when 在oracle中如何用? 想购买C#写的数据库程序,具体要求如下: 我要随时捕获用户输入的键,如Ctrl+c,请问怎么实现? 谁有.net下实现ipx-spx的例子 如何c#中执行一个命令行程序,如rar e Test.rar
Server.Tranfer(Url)
就可以
FormsAuthentication.RedirectFromLoginPage(string, bool);
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或密码错误";
}
//}
}
http://..../login.aspx?u=#######然后登录完读取#####再跳回去不就结了么
Uri MyUrl = Request.UrlReferrer;
BackURL.Text = MyUrl.AbsoluteUri.ToString();
FormsAuthentication.RedirectFromLoginPage(string, bool);