繁体   English   中英

表单身份验证问题 - 身份验证后无法从登录页面重定向到主页

[英]issue with forms authentication - Unable to redirect from login page to home page after authentication

在Sharepoint 2010中,我们使用经典身份验证创建了一个Web应用程序,并开始开发它。 稍后,我们希望对项目实现表单身份验证,因此我创建了一个新的SharePoint Web应用程序,并启用了基于表单的身份验证。 我拿了旧网站的备份(经典版权所有)并恢复到新网站(fba)。 我按照以下链接实现了表单身份验证:

使用IIS7为SharePoint 2010配置基于表单的身份验证

我创建了一个自定义登录页面。 输入有效凭据后,用户不会重定向到主页。 身份验证正常进行,但不会重定向到主页。 当我点击登录按钮时,它再次加载相同的登录页面。 请找到以下代码进行身份验证和重定向到主页:

protected void btnLogin2_Click(object sender, EventArgs e)
{
  if (Membership.ValidateUser(txtUserId.Value, txtPassword.Value))
  {
    string link = "http://ejudnam:36414/sites/Prototype/Dashboard/Pages/default.aspx");

    Response.Redirect(link);

    //I tried with the below line also but it is of no use
    // SPUtility.Redirect(link, SPRedirectFlags.Default, this.Context);
  }  
  else
  {
    lblMessage.Text = "Login Failed.";
  }
}

我们无法弄清楚这个问题。 我尝试了很多解决方案,但它们毫无用处。

请使用SPClaimsUtility在基于声明的应用程序中授权用户。

从。\\ assembly \\ GAC_MSIL \\ Microsoft.SharePoint.IdentityModel \\ 14.0.0.0__71e9bce111e9429c \\ Microsoft.SharePoint.IdentityModel.dll添加Microsoft.SharePoint.IdentityModel DLL引用以访问SPClaimsUtility

试试这个:

  SPSecurity.RunWithElevatedPrivileges(delegate()
        {
           bool status = SPClaimsUtility.AuthenticateFormsUser(Context.Request.UrlReferrer, txtUserId.Value, txtPassword.Value);
           if (status)
              {
               string link = "http://ejudnam:36414/sites/Prototype/Dashboard/Pages/default.aspx";
              Response.Redirect(link);
              }
        });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM