Failed to load type - custom view based on ViewPage

I am working on creating a new base class for an asp.net application to create my own version of a strongly typed view from MVC. However, the application is not an MVC application. Below is the base of my custom class.

public class BasePage<T> : Page where T : IPageInfo
{
    public BasePage()
    {
        this.MyPageInfo = IoC.GetInstance<IPageInfo>(); //pseudo-code to populate a property.
    }
}

When I add a new WebForm page to my application, I change the "inherits" attribute in the "Page" directive to point to this BasePage class instead of the regular code class in the same way as ASP.Net MVC typed Views. The following is an example of a page directive.

<%@ Page language="C#" inherits="MyApp.Core.BasePage<MyApp.Content.Search>"%>

In the directive above, the MyApp.Content.Search class implements the IPageInfo interface, which BasePage must satisfy common type constraints.

, , Could Not Load Type. MVC 2, , ViewPage , , , . -, MVC , MVC. , MVC; BasePage . ( ).

- , ?

+3
1

, <%@ Page language="C#" inherits="MyApp.Core.BasePage<MyApp.Content.Search>"%> MyApp.Core.BasePage, ​​ ASP.NET MVC. System.Web.Mvc.ViewTypeParserFilter:

<pages
    validateRequest="false"
    pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
    userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    <controls>
        <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
    </controls>
</pages>
+4

Source: https://habr.com/ru/post/1754233/


All Articles