1

我有一個使用Identity Server 4的本地運行良好的asp.net核心MVC應用程序。然而,當我把它部署到Azure的應用程序服務(部署會自動執行基於在辦理入住手續所以沒有手動步驟)應用程序未能按預期已部署的asp.net核心mvc應用程序在azure中不可瀏覽

我可以工作:

  • 訪問靜態文件出WWW根目錄的
  • 訪問。嗯知名/ OpenID的配置,看看JSON返回

我不能:

  • 瀏覽網頁並獲取身份服務器歡迎頁面
  • 查看任何MVC「頁面」(e..g /帳號/登錄)

我的配置方法是不是特別複雜:

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?}"); 
      }); 

但是MVC方面似乎沒有任何功能。當我瀏覽網頁我只是得到了視圖無法找到:

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 

回答

4

檢查publishOptionsproject.json文件 - 你有款include部分。你需要在這裏添加一個相對路徑到「Views」文件夾。

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

哇。我甚至不知道這個部分存在。如何/爲什麼它會在沒有Views文件夾的情況下創建?我已經在wwwroot/Views/areas/appsettings/web.config中添加了它的工作。謝謝 :) – LDJ

相關問題