Microsoft Graph API重定向成功但Request.Authentication = false

问题描述 投票:0回答:1

在ASP.NET C#it中成功验证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中看到状态问题的日志时,它说它成功了。

enter image description here

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

c# asp.net azure active-directory owin
1个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.