DavidT DavidT - 1 year ago 174
ASP.NET (C#) Question

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


  • .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.

Answer Source

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


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

"publishOptions": {
  "include": [
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download