Identity Working Locally but not after deploying to Azure

Ben G 0 Reputation points
2024-04-29T03:05:39.01+00:00

Hello,

When I deployed my Razor Pages project using asp.net and EF 8 to Azure, now when I login, the site simply refreshes and does not login. Also, the pages I had listed with [Authorize] are not requiring to be logged in. They seem to be viewable by public.

I have the return redirect in my login.cshtml.cs set as:

public async Task
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,002 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,797 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ben G 0 Reputation points
    2024-05-01T03:56:08.6733333+00:00

    I was missing app.Endpoints as my middleware, updated my program.cs as below:

    app.UseAuthentication(); // For identity
    app.UseRouting();
    app.UseAuthorization(); // For identity
    app.UseEndpoints(endpoints =>
    {
        endpoints.MapControllers();
        endpoints.MapRazorPages();
    });
    
    
    0 comments No comments