Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am getting:

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

when I browse to my index.cshtml file. It is very simple:

@using System.Web.Optimization
@inherits System.Web.Mvc.WebViewPage
<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width">
    <title>Hello World</title>
    @Styles.Render("~/Content/css", "~/Content/themes/base/css")
    @Scripts.Render("~/bundles/modernizr")
</head>
<body>
    @Scripts.Render(
        "~/bundles/jquery",
        "~/bundles/jqueryui"
    )
</body>
</html>

my index.cshtml file is outside of the Views folder, if that matters at all.

like image 1000
O.O Avatar asked Mar 24 '13 01:03

O.O


1 Answers

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.

like image 75
Yogurtu Avatar answered Oct 16 '22 20:10

Yogurtu