Deployed asp.net core mvc app not browsable in azure

徘徊边缘 提交于 2019-12-11 06:38:21

问题


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:


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",
      ...
    ]
  },
}


来源:https://stackoverflow.com/questions/40717145/deployed-asp-net-core-mvc-app-not-browsable-in-azure

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!