Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The view must derive from WebViewPage

I had a working MVC application when I decided that it was time for some maintenance. My views were all under SHARED directory and I decided to move them into separate directories.

I implemented a CustomViewEngine that I found here: Can I specify a custom location to "search for views" in ASP.NET MVC?

View structure looks something like this

Views
    AppViews
    OtherAppViews
    ...
    Shared
    ...

This is an error that I am getting:

The view at '~/Views/AppViews/SomeView.cshtml' must derive from ViewPage, ViewPage<TModel>, ViewUserControl, or ViewUserControl<TModel>.

I tried to inherit from @inherits System.Web.Mvc.WebViewPage (as explained here: The view must derive from WebViewPage, or WebViewPage<TModel>) , but when I do this I get an error saying that I can't use @inherits and @model at the same time.

like image 226
gumenimeda Avatar asked Sep 03 '13 16:09

gumenimeda


1 Answers

Your CustomEngine should derive from RazorViewEngine instead of WebFormViewEngine since you use .cshtml files (Razor engine).

Docs:

  • RazorViewEngine
  • WebFormViewEngine
like image 167
Melodron Avatar answered Oct 14 '22 13:10

Melodron