Type 'ASP._Page_index_cshtml' does not inherit from 'System.Web.WebPages.WebPage'

Do not remove the inheritance, it might be necesary and might lead to another problems in the future.

Instead try this:

Enable "View all Files" in the web project that is failing, and search for a file that seems correct but is not included in visual studio, and delete it. If it fails in your deployment folder, try to clean the folder as well, and re-deploy the site, you might have unnecesary files that might cause the same problem.

In my case, at the root of the webproject I had an extra copy of _ViewStart.cshtml (excluded from the project), I deleted that file, and that did the trick.

Hope it helps, let me know if this solve your problem as well.


I just had to remove: @inherits System.Web.Mvc.WebViewPage

Looks like I had a copy paste error when reorganizing my project.


I change the cshtml line from:

Layout = "~/Views/_ViewStart.cshtml";

to

Layout = "~/Views/Shared/_Layout.cshtml";

since _ViewStart.cshtml contains only that line of code. Layout file was required because it contains the script to client-side validation.

It worked also when I remove the line, but I prefer to keep _Layout.cshtml included.