Generic Inherited ViewPage<> and new Property

Viewed 11405

Setup:

  • CustomViewEngine
  • CustomController Base
  • CustomViewPage Base (in this base, a new property is added "MyCustomProperty")

Problem:

When a view is strongly typed such as: <@ Page Inherits="CustomViewPage<MyCustomObject" MyCustomProperty="Hello">, I get a compiler "Parser" error stating that MyCustomProperty is not a public property of System.Web.Mvc.ViewPage

I have done numerous trial and errors (see below) to see whats causing this error and have come to the following conclusions:

  • The error only occurs when I declare "MyCustomProperty" or any other property in the @Page directive of the view.
  • The error will always display "System.Web.Mvc.ViewPage" rather than the declared inherits=".." class.
1 Answers
Related