Anton Gildebrand Anton Gildebrand - 1 year ago 113
C# Question

Could not load file or assembly 'System.Web.WebPages'

I've had this problem before, but then all i needed to do was to clean and rebuild the project. Now that doesnt seem to work anymore. When i start my Asp.Net MVC3 project debugger, the site is opened in my browser. Instead of getting the first page presented in the browser, i get this error

Parser Error Message: Could not load file or assembly 'System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

Source Error:
Line 31: <add assembly="System.Web.Routing, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 32: <add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 33: <add assembly="System.Web.WebPages, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 34: </assemblies>
Line 35: </compilation>

I can't seem to figure out how to solve this. Any idea?

Answer Source

I had this problem. Maybe it occurred when I installed .NET MVC v4 over the top of MVC v3, not sure.

Anyway I removed the System.Web.WebPages reference from my project. Then in the Add Reference dialogue .NET tab there were two System.Web.WebPages references listed, a version and a I made sure to add the version one as that was the one that was missing.

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download