Azure MVC cannot find view or master by default route, but works locally

I have an MVC website that works fine, but locally, but when I deploy it on 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 additional information if necessary, but I could not find anyone with the same problem in all reports about this problem. Most people legally have a problem with a file in the wrong place. But my structure of controllers and views is beautiful, they work locally. He just does not find the "View" when it is deployed to my Azure Website.

+6
source share
4 answers

In the properties of each view, I had to change the Build Action to Content, and the publication actually deployed the .cshtml files.

+13
source

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" ] }, 
+2
source

Make sure your view is actually copied to the server.

From Visual Studio, right-click on the view, select "Properties" and set the "Copy to output directory" property. Maybe you selected "Don't copy"?

For deployment options on Azure, I would recommend this article .

This can also be a problem with routing - see here .

+1
source

I had this problem and the view was removed from the .csproj file using git co-merge. It took a while to figure this out. Hope this helps someone.

0
source

Source: https://habr.com/ru/post/985307/


All Articles