1
votes

I have an asp.net core MVC application using Identity Server 4 which runs fine locally. However, when I deploy it to an Azure app service (the deploy is performed automatically based on check-in so no manual steps) the app fails to work as expected

I can:

  • Access static files out of the www root directory
  • Access .well-known/openid-configuration and see the JSON returned

I cannot:

  • Browse to the homepage and get the Identity server welcome page
  • View any MVC “pages” (e..g /account/login)

My configure method isn’t particularly complex:

loggerFactory.AddConsole();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseIdentityServer();
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationScheme = IdentityServerConstants.ExternalCookieAuthenticationScheme,
                AutomaticAuthenticate = false,
                AutomaticChallenge = false
            });



            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

But nothing on the MVC side seems to be functioning. When I browse to the homepage I simply get the View cannot be found:

An unhandled exception occurred while processing the request.
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
1

1 Answers

4
votes

Check publishOptions section in project.jsonfile - you have section with subsection include. You need to add a relative path to "Views" folder here.

{
  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      ...
    ]
  },
}