ASP.NET登录表单身份验证,不使用登录控件。

3
我正在使用ASP.NET会员功能,在注册页面上尝试在没有登录控件的情况下进行登录。
当用户单击注册按钮时,控制流转到redirect.aspx页面。 但是在该页面中,当我尝试重定向到会员主页时,它会抛出以下错误。
错误 -
Unable to evaluate expression because the code is optimized or a native frame
is on top of the call stack.

Web.config -

<authentication mode="Forms">
    <forms name=".SSOAuth" loginUrl="login.aspx" defaultUrl="Redirect.aspx"
           protection="Validation" timeout="30000"/>
</authentication>

注册页面代码 -

protected void btnRegister_Click(object sender, EventArgs e)
{
    MembershipUser userMemb = Membership.CreateUser(
                           txtemail.Text.Replace("'", "''").ToString(),
                           txtPassword.Text.Replace("'", "''").ToString(),
                           txtemail.Text.ToString());

    Roles.AddUserToRole(txtemail.Text.ToString(), "Member");
    FormsAuthentication.RedirectFromLoginPage(txtemail.Text.Trim(), false);
}

Redirect.aspx.cs代码 -

try
{
    if (User.IsInRole("Member"))
    {
        string UserName = User.Identity.Name;                        
        Response.Redirect("~/Member/MembeHome.aspx");
    }
}
catch(Exception ex) {}
1个回答

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接