【问题标题】:Microsoft Graph API Redirect successfully but Request.Authentication=falseMicrosoft Graph API 重定向成功,但 Request.Authentication=false
【发布时间】:2019-03-13 08:31:54
【问题描述】:

在 ASP.NET C# 中成功对 Azure AD 进行身份验证后,主页未按身份验证。

 @if (Request.IsAuthenticated)
    {
        <h4>Welcome @ViewBag.User.DisplayName!</h4>
        <p>Use the navigation bar at the top of the page to get started.</p>
    }
else
    {
       //Its going in Else condition
        @Html.ActionLink("Click here to sign in", "SignIn", "Account", new { area = "" }, new { @class = "btn btn-primary btn-large" })
    }

但是当我在 Azure 中看到状态问题的日志时,它说它成功了。

当我尝试在本地 Visual Studio 中进行调试时,一切正常,它在 IsAuthenticated 中作为 true 并且工作完美。但是,当我们在生产中发布此问题时,唯一的问题是如上所述。

【问题讨论】:

标签: c# asp.net azure active-directory owin


【解决方案1】:

如果您使用的是 Dot net core,那么只需在 Startup.cs 类的配置方法中的 app.UserMvc(...) 之前调用 app.UseAuthentication()。

你也可以看看这个帖子WebForms Forms Authentication: Request.IsAuthenticated=false after successful log in and redirect。但是

【讨论】:

  • 谢谢,我们会检查并回复您。
  • 对不起,我的回复晚了,但这不适用于我的项目。但当时我的公司不想再使用 azure 登录。再次感谢。
猜你喜欢
  • 1970-01-01
  • 2020-03-04
  • 2020-10-03
  • 2019-12-08
  • 1970-01-01
  • 2021-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多