After successful authentication for Azure AD in ASP.NET C# it, the home page is not getting in as authenticated.

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

But when I see the log in the Azure for the status problem it says it success.

enter image description here

When I try to debug in Visual Studio Locally everything works fine it goes in the IsAuthenticated as true and works perfect. But the only problem in when we publish this in Production the problem arise as explained above.

1 Answers

MohitVerma-MSFT On

If you are using Dot net core then just Call app.UseAuthentication() before app.UserMvc(...) in Configure Method in your Startup.cs class.

Also You can take a look at this thread WebForms Forms Authentication: Request.IsAuthenticated=false after successful log in and redirect. But