ASP.NET MVC - Why is my view not inheriting properly from System.Web.Mvc.ViewPage (from T)

It should be possible here to use generics and pass the class type of the model. However, Visual Studio 2008 is not accepted:

<%@ Page Inherits="System.Web.Mvc.ViewPage(of IEnumerable(of MyNamespace.MyClass))" %>

I get the following validation error (underlined in VS): 'Context' is not a member of 'ASP._views___home___index__asp'

I get the following runtime error: BC30456: 'InitializeCulture' is not a member of 'ASP._views___home___index__asp'.

Note. I am using Visual Basic.NET, but this should not affect the problem.

Here are some screenshots of the views and controllers, I hope someone sees what happens (TestClass is a simple class with the ID and Name property):

, Maik Koster , :

  • System.Web.Mvc( GAC, )
  • . → ...

ASP.NET MVC page inherits :

<%@ Page Inherits="System.Web.Mvc.ViewPage" %>
+3
5

, IDisposable.

: System.Data.Objects System.Data.Objects.DataClasses. System.Data.Entity web.config,

<add assembly="System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

. .

+5

:

<%@ Page Inherits="System.Web.Mvc.ViewPage<IEnumerable<MyNamespace.MyClass>>" %>
+2
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyProject.Helpers.PaginatedList<MyProject.Models.Person>>" %>

, .

+1

MVC1. . , .

0

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


All Articles