aspnetcore: Exception handler causes a 404

Describe the bug

I deployed a website on Azure Webapp with Azure AD, i created the webapp with the command: dotnet -o webapp -au SingleOrg -clientId [...]

So i got a sample web app with AzureAD Authentication Azure AD Ui in Nuget dependance to handle the user AD Authentication.

In local it works pretty well (y)

But when i deployed with azure devops in Azure Web App, i received a 404 not found for: /AzureAD/Home/SignIn Areas:AzureAD Controller:Account Action:SignIn

I have no idea why, i didn’t find issues wich solve this problem.

To Reproduce

Create a sample web app and deploy on basic azure Web App (with azure cli)

Appsettings :

{
  "AzureAd": {
    "Instance": "my_instance_url",
    "Domain": "my_domain_url",
    "TenantId": "dummydummy",
    "ClientId": "dummydummy",
    "CallbackPath": "/signin-oidc"
}

Startup.cs > ConfigureServices


        public void ConfigureServices(IServiceCollection services)
        {
// ...
            services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
                    .AddAzureAD(options => Configuration.Bind("AzureAd", options));

            services.AddControllersWithViews(options =>
            {
                var policy = new AuthorizationPolicyBuilder()
                    .RequireAuthenticatedUser()
                    .Build();
                options.Filters.Add(new AuthorizeFilter(policy));
            });
// ...
}

Startup.cs > Configure

  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
// ...
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "areas",
                    pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "Home/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
// ...
     }

Get 404 response, the Area Azure AD is not found.

Kudu confirm Azure Ad UI Dlls are here :

  • Microsoft.AspNetCore.Authentication.AzureAD.UI.dll - 34kb
  • Microsoft.AspNetCore.Authentication.AzureAD.UI.Views.dll -26kb

Did i miss something or there is an issue about import of area in external package ?

Further technical details

  • ASP.NET Core 3.1
  • Azure Web App (no Authentication configured)

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

What do the server logs report? https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-3.1#configuration

I’ve seen this happen if there was an exception and then it couldn’t find the error page.