2016-07-19 43 views
5

部署應用上IIS 8.5,Asp.net芯Asp.net核心+ IIS 8.5:視圖 '索引' 未找到

3的應用,前端,API和登錄(在同一地點);

所有3個都在VS2015的IIS Express中完成工作;

前端(僅HTML/AngularJS)& API在IIS 8.5

但對於登錄完美的工作(IdentityServer4):

InvalidOperationException: The view 'Index' was not found. The following locations were searched: 
- ~/UI/Home/Views/Index.cshtml 
- ~/UI/SharedViews/Index.cshtml 

據我所知, '〜/' 是指批准;

我的VS2015結構:
Visual Studio 2015 project structure

測試/檢查:

  • .UseContentRoot(Directory.GetCurrentDirectory())在Program.cs中
  • 所有的權限IIS_IUSRS用戶帳戶的服務器上
  • CustomViewLocationExpander:

    public class CustomViewLocationExpander : IViewLocationExpander { 
    
        public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations){ 
         yield return "~/UI/{1}/Views/{0}.cshtml"; 
         yield return "~/UI/SharedViews/{0}.cshtml"; 
        } 
    
        public void PopulateValues(ViewLocationExpanderContext context) 
        { 
        } 
    } 
    

我可以自由地訪問在 'wwwroot的' 只有JS /圖片/ CSS的所有內容

我就這一個毫無頭緒。

+0

您是否檢查您是否部署了視圖?你可以分享你的project.json的樣子嗎? –

+0

我忘了在project.json的publishOptions元素中的「wwwroot」旁邊添加「UI」文件夾 – DavidT

回答

5

我在發帖之前搜索了一個多小時。休息了一下,發現這個:

https://github.com/IdentityServer/IdentityServer4.Samples/issues/23

添加「UI」在project.json發佈選項

"publishOptions": { 
    "include": [ 
    "wwwroot", 
    "UI", 
    "YourCertificateName.pfx", 
    "web.config" 
]} 

精度:「UI」指的是「根」文件夾中包含我的看法。您必須將它們全部(根視圖文件夾)包含在「publishOptions」中才能導出。

+0

對於無用和錯誤的編輯,我感到抱歉。太多的編碼時間,我認爲我的大腦即將關閉昨晚...無論如何感謝您的回答 –

+0

我知道你說過這個,但我不明白你的意思。請注意,「UI」是指包含視圖的文件夾的名稱。我被稱爲「視圖」,所以添加「UI」到我的publishOptions不起作用:-p –