.net razor error dynamic objects

‘object’ does not contain definition for ‘PropertyName’ when using Razor and dynamic objects

If you are trying to pass anonymous dynamic objects to a Razor view you will run into this error. That is because as of C# 5.0 anonymous dynamic objects are compiled as internal. Considering that views are compiled into a completely separate assembly from controllers, by the time your view model is reaching Razor it […]

0 Comment