Search code examples
c#azureasp.net-coreasp.net-core-mvcidentityserver4

IdentityServer on Azure


I'm trying to make an ASP.NET Core Web application to host IdentityServer and use it as my main authorization service, shared across many other apps.

I followed the quick start tutorial that consists in installing a nuget package (called IdentityServer4) in an empty MVC application template.

Everything is working fine on my machine (debugging with VS2017 & VS2019 preview). I tried to publish the app as an Azure App Service like i did with previous apps and worked fine.

While debugging, if i open a browser and type "https://localhost:44316/", i see this page:

enter image description here

But navigating to "https://xxx.azurewebsites.net" (that is where i published the app) is not working. Responding 404 not found.

Just to add some detail, if i navigate this "https://localhost:44316/Account/Login?ReturnUrl=%2Fgrants", i obtain the correct login page and doing the same on Azure produces the same result.

So, essentially, looks like it's working, except for the home page.

I'm not an expert in routing with ASP.NET Core, so don't blame me if my question is not so smart.


Solution

  • So, essentially, looks like it's working, except for the home page.

    This is actually the intended behaviour - If you take a look at the implementation of the HomeController provided in the IdentityServer4.Quickstart.UI project, you'll see the following implementation (source):

    public IActionResult Index()
    {
        if (_environment.IsDevelopment())
        {
            // only show in development
            return View();
        }
    
        _logger.LogInformation("Homepage is disabled in production. Returning 404.");
        return NotFound();
    }
    

    When running in Azure, the application's environment isn't set to Development environment and so returns 404 NotFound, as shown above.