Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net Core + IIS 8.5 : The view 'Index' was not found

Deployed App on IIS 8.5, Asp.net core

3 apps, Front-end, API and Login (on the same site);

All 3 are working PERFECTLY in IIS express from VS2015;

The front-end (only html/AngularJS) & API are working perfectly on IIS 8.5

But for the Login (IdentityServer4):

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

I understand that '~/' refers to the approot;

My VS2015 structure:
Visual Studio 2015 project structure

Tested/Checked:

  • .UseContentRoot(Directory.GetCurrentDirectory()) in Program.cs
  • All privileges to IIS_IUSRS user account on the server
  • 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)
       {
       }
    }
    

I can access all content freely on 'wwwroot' only js/images/css

I'm clueless on this one.

like image 411
DavidT Avatar asked Jul 19 '16 19:07

DavidT


1 Answers

I searched for more than an hour before posting. Took a break and found this :

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

add "UI" to the publish options in project.json

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

Precision : "UI" Refers to the 'root' folder containing my views. You have to include them all (root view folders) in "publishOptions" to be exported.

like image 148
DavidT Avatar answered Sep 28 '22 03:09

DavidT