Yousuf Yousuf - 1 year ago 83
ASP.NET (C#) Question

.net core mvc application error after publishing to iis

I am trying to host .net core mvc application in iis. When I publish I get below error -


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

Set Set
Answer Source

You need to add Views folder to publishing. In you project.json file you have section publishOptions with subsection include. Add relative path to "Views" folder here

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