【发布时间】: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 并且工作完美。但是,当我们在生产中发布此问题时,唯一的问题是如上所述。
【问题讨论】:
-
WebForms Forms Authentication: Request.IsAuthenticated=false after successful log in and redirect 的可能重复项。但是,如果您使用的是 Dot net core,那么只需在 Startup.cs 类的 Configure Method 中的 app.UserMvc(...) 之前调用 app.UseAuthentication()。
标签: c# asp.net azure active-directory owin