Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Azure can't find view or master with default route but works locally

I have an MVC website that works fine running locally but when I deploy it to my Azure Website I get this error for every webpage except the Home Index page.

The view 'Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Sales/Index.aspx
~/Views/Sales/Index.ascx
~/Views/Shared/Index.aspx
~/Views/Shared/Index.ascx
~/Views/Sales/Index.cshtml
~/Views/Sales/Index.vbhtml
~/Views/Shared/Index.cshtml
~/Views/Shared/Index.vbhtml

I can provide more information, if necessary, but I haven't been able to find anyone with the same issue in all the reports of this issue. Most people legitimately have the issue of the file in the wrong place. But, my structure of Controllers and Views are fine, they work locally. It only fails to find the Views when its deployed to my Azure Website.

like image 650
Khaneliman Avatar asked Apr 16 '15 23:04

Khaneliman


2 Answers

In the properties of each of the views I had to change the Build Action to Content and the publish actually deployed the .cshtml files.

like image 138
Khaneliman Avatar answered Oct 12 '22 23:10

Khaneliman


For those with an ASP.NET Core application, the solution was to add "Views" to the publishOptions.include array:

"publishOptions": {
  "include": [
    "wwwroot",
    "Views",
    "web.config"
  ]
},
like image 37
bdimag Avatar answered Oct 12 '22 22:10

bdimag