C# Microsoft Graph API重定向成功,但请求。身份验证=false
在ASP.NET C#it中成功验证Azure AD后,主页不会以已验证身份进入C# Microsoft Graph API重定向成功,但请求。身份验证=false,c#,asp.net,azure,active-directory,owin,C#,Asp.net,Azure,Active Directory,Owin,在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 {
@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" })
}
@if(Request.IsAuthenticated)
{
欢迎@ViewBag.User.DisplayName!
使用页面顶部的导航栏开始
}
其他的
{
//它在其他情况下运行
@ActionLink(“单击此处登录”、“登录”、“帐户”、新建{area=”“}、新建{@class=“btn btn primary btn large”})
}
但是当我在Azure中看到关于状态问题的日志时,它说它成功了
当我尝试在VisualStudio中进行本地调试时,一切都很好,它进入了一个被验证为true并且工作完美的环境。但是,当我们在生产中发布此文件时,唯一的问题是如上所述出现的问题。如果您使用的是Dot net core,则只需在
Startup.cs
类的Configure方法中调用app.UseAuthentication()
之前调用app.UserMvc(…)
你也可以看看这条线。但是可能重复的。但是,如果您使用的是Dot net core,则只需在Startup.cs类的Configure方法中的app.UserMvc(…)之前调用app.UseAuthentication()。谢谢您的检查并返回给您。很抱歉我的答复太晚,但这对我的项目不起作用。。但当时我的公司不想再使用azure登录。再次感谢。