0

After migration from MVC 4 to MVC 5 got an exception:

Could not load type 'System.Web.Mvc.ViewMasterPage<PropertyViewModel>'. Could not load type 'System.Web.Mvc.ViewMasterPage<PropertyViewModel>'. Could not load type 'System.Web.Mvc.ViewMasterPage<PropertyViewModel>'.

It occurs on @Html.DIsplayFor(x=>x.MyModel.Title) where title is empty String.

Before the update everything was working.

Updated: who has experience in MVC, please help. After update web.config with these:

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

i`ve got - Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. How i can fix it?

Victor
  • 201
  • 3
  • 10

1 Answers1

0

Make sure you include your namespace for that ViewModel.

Here's an example:

@model MiniRegistration.Web.Areas.Home.ViewModels.RegistrationViewModel

Also check that the web.config file located in your View Directory, has the following page directives:

<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"> 

This website breaks it down nicely:

http://www.codewrecks.com/blog/index.php/2009/04/05/could-not-load-type-systemwebmvcviewpage/

And this post reflects a similar problem to yours with a solution as well: ASP.NET MVC Strongly Typed Partial View, gives could not load type error

Community
  • 1
  • 1
Dayan
  • 7,634
  • 11
  • 49
  • 76
  • Thanks for so quick repsonse. I've tried this solution before - no result. The exception actually changes to new one: Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. Exception of type 'System.Web.HttpUnhandledException' was thrown. Exception of type 'System.Web.HttpUnhandledException' was thrown. – Victor Mar 25 '14 at 20:57
  • And why old code (without any changes) for MVC 4 works perfectly, but after update, i need to modify web.config? – Victor Mar 25 '14 at 21:43
  • @Victor Are you able to build your project without problems? If so, Check your `Views` Make sure there's no syntax errors in place. You can also put a break-point on some of your controllers to step through and see which one raises the exception. – Dayan Mar 26 '14 at 13:17
  • I can build whole solution without any problems or errors. Problems fired only when run the code. – Victor Mar 27 '14 at 08:50
  • @Victor When your able to build your solution just fine, the problem falls under the `Views` which is where the `System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper` comes into play. There should be more details on the Stacktrace, more than likely pointing to some web control or syntax error on your view. If anything, try to load up Firefox's Firebug or something of the sort and see if it catches any errors. – Dayan Mar 27 '14 at 12:48