carl saptarshi
carl saptarshi

Reputation: 355

ASP.NET MVC5 -I followed the Instructions and i constantly get Type 'ASP._Page_index_cshtml' does not inherit from 'System.Web.WebPages.WebPage' error

I am brand new to ASP.NET - and was following some tutorials. below are the screen shots that show what i have done exactly as recommended and in turn it worked for them, but for some reason i keep getting this error and have no idea what to - I am using MVC5 on VS Community : Could someone help me figure out where I have gone wrong? I do not even know where to begin :(

screenshot1: Movie.cs (my Model)

Screenshot2: MoviesController.cs (my Controller)[![][2]]3 [enter image description here]4

Upvotes: 1

Views: 108

Answers (1)

Nikhil Vartak
Nikhil Vartak

Reputation: 5117

You have referenced _ViewStart.cshtml file and that's not correct. This file and it's name has a special meaning to MVC framework. You cannot specify it, it is picked up internally by framework.

  1. If you intend to set a layout file then change the name of that file.
  2. If it is really a view start file then remove that Layout property assignment.
  3. If you want a better way, open up view start file and set the layout property in it.

_BasicLayout.cshtml

<!DOCTYPE html>
<html>
<head>
    <title>@ViewBag.Title</title>
</head>
<body>
    <div>@RenderBody()</div>
</body>
</html>

_ViewStart.cshtml

@{
    Layout = "~/Views/_BasicLayout.cshtml";
}

Index.cshtml

@{
    ViewBag.Title = "Index view does not need to reference _VewStart.cshtml explicitly";
}

Upvotes: 2

Related Questions