First of all thanks to Andrea Balducci that gave me this solution. I have a asp.net application where I enabled Asp.Net mvc following a link in the web. Everything works well until I try to use Strongly Typed View. When I try to have a page that inherits from ViewPage<T> where T is one of my model the system gave me an error of type
Could not load type ‘System.Web.Mvc.ViewPage<…>
In a asp.net site created with the wizard everything works ok. I check both web.config to be sure that actually I did not forgot anything, then I stumble across this post. Basically I need to modify Page directive of my web config in this way
<pages pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
I really do not understand why the site created with the asp.net wizard works because it does not have this directive, then Andrea told me to chek the View directory, because it has a dedicated web.config. Here is the solution. The view directory must contains a web.config like this
<?xml version="1.0"?> <configuration> <system.web> <httpHandlers> <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> </httpHandlers> <!-- Enabling request validation in view pages would cause validation to occur after the input has already been processed by the controller. By default MVC performs request validation before a controller processes the input. To change this behavior apply the ValidateInputAttribute to a controller or action. --> <pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <controls> <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> </controls> </pages> </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <handlers> <remove name="BlockViewHandler"/> <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/> </handlers> </system.webServer> </configuration>
Thanks again to Andrea for the solution.
alk.
Tags: ASP.NET Mvc






April 6th, 2009 at 1:19 pm
i had the same issue upgrading from preview5 to Rc1, so i knew where to look for
April 20th, 2009 at 5:23 am
Thanks for the post. I’m currently trying to mix ASP .NET Web Forms and MVC, by placing ViewPages on ordinary MasterPage. So this worked.
April 20th, 2009 at 12:41 pm
I think that actually the best approach is using both webform and mvc in the same site. Having the powerful RAD approach of webforms can be really useful to realize backoffice pages, leaving mvc and client side rendering for the public part of the site.
Moreover you can obtain a good separation from logic and view even with webforms, if you isolate all of your logic into services and then access those services, even with the objectDataSource, you can reach a good testability without MVC.
Surely, MVC structured pages are more testable and moreover MVC pattern forces you to separate logic and view, and I really prefer full control over html that you cannot have in webform enviroments.
Alk.
May 22nd, 2009 at 1:14 am
Thanks for this post, was debugging for so long
October 21st, 2009 at 10:40 am
Thanks a lot, i spend a long time to find solution for this error. You help me to save a lot time.
January 18th, 2010 at 9:10 pm
Thank you!! I was about to strangle somebody.
February 5th, 2010 at 2:57 am
I too had this problem for the same reason (integrating into an existing ASP.NET site) Found the problem at
http://forums.asp.net/t/1378448.aspx
You need to look at the Web.config that the normal MVC project puts in the VIEWS folder – always was puzzled by that.
Dave
February 12th, 2010 at 2:20 am
I’m trying to run MVC in a web site project and was missing that Views web.config file. Thanks!
February 18th, 2010 at 3:55 pm
worked perfectly! thank you!
February 23rd, 2010 at 2:00 pm
THANKS!
Had exactly the same problem and this of course solved it
April 1st, 2010 at 8:23 pm
Thanks! Had removed sub folders and my publish didn’t copy the config files (so no overwrites). Didn’t realize there was one hidden!