FormsAuthentication.RedirectFromLoginPage问题

[复制链接]
查看11 | 回复1 | 2010-5-13 20:14:54 | 显示全部楼层 |阅读模式
我在A页面点击的时候会进入登录界面,但是登录成功后却跳到了Default.aspx,不能转向原来的页面,请帮忙看一下是什么问题
登录代码:
protected void Button1_Click(object sender, EventArgs e)

{

string strConn = "server=WIFI-397CEB5740;database=dan;uid=sa;pwd=";

string strCmd = "select * from [user] where(userid='" + TextBox1.Text + "'and password='" + TextBox2.Text + "')";

SqlConnection myConnection = new SqlConnection();

myConnection.ConnectionString = strConn;

SqlCommand myCommand = new SqlCommand(strCmd, myConnection);

myCommand.Connection.Open();

SqlDataReader myReader = myCommand.ExecuteReader();

if (myReader.Read())

{

Session["user"] = TextBox1.Text ;

FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);



}

else

{

Label1.Text = "对不起!用户名或密码错误,请重新输入";

TextBox1.Text = "";

TextBox2.Text = "";

}

myCommand.Connection.Close();

myConnection.Close();

}
web.config设置





ReturnURL 需要自己定义吗,要的话要怎么写

回复

使用道具 举报

千问 | 2010-5-13 20:14:54 | 显示全部楼层
RedirectFromLoginPage 方法重定向到查询字符串中使用 ReturnURL 变量名指定的返回 URL。例如,在 URL http://www.contoso.com/login.aspx?ReturnUrl=caller.aspx 中,RedirectFromLoginPage 方法重定向到返回 URL caller.aspx。如果 ReturnURL 变量不存在,RedirectFromLoginPage 方法将重定向到 DefaultUrl 属性中的 URL。当浏览器重定向到登录页时,ASP.NET 将自动添加返回 URL。默认情况下,ReturnUrl 变量必须引用当前应用程序中的页。如果 ReturnUrl 引
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行