5

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.

Luke Girvin
  • 12,913
  • 8
  • 60
  • 81
gumenimeda
  • 795
  • 6
  • 13
  • 42

1 Answers1

10

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

Docs:

Mike Szyndel
  • 10,124
  • 7
  • 44
  • 61
Melodron
  • 113
  • 1
  • 9