I ran into this issue with a Web Application – my .cshtml
files got stuck on the System.Web.WebPages.WebViewPage
base class when I needed the System.Web.Mvc.WebViewPage
.
First, ensure your ~/Views/web.config file has the correct pageBaseType
. In my case, I set to System.Web.Mvc.WebViewPage
.
<configuration>
<system.web.webPages.razor>
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<!-- ... -->
</pages>
</system.web.webPages.razor>
</configuration>
Then, importantly, some people have found this is key if the above is already good:
- Run a clean on the solution
- Unload the project with the issues
- Delete the
.user
file that Visual Studio generated next to the project. - Reload the project with the issues
- Build the solution
For VS2015, the .user
and .sln
files have moved to the .vs
hidden folder that is created next to the .sln
file. However, from comments below, the error messages imply to me that the tooling is using the wrong version of MVC entirely, and deleting this folder does not fix the issue. To my knowledge, there is not a known solution.