Reputation: 3707
I've had this problem before, but then all I needed to do was to clean and rebuild the project. Now that doesn't 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=1.0.0.0, 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=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 32: <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 33: <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
Line 34: </assemblies>
Line 35: </compilation>
I can't seem to figure out how to solve this. Any idea?
Upvotes: 39
Views: 103499
Reputation: 1587
Go to menu: "Tools / Nuget Package Manager / Package Manager Console"
run command install-package Microsoft.AspNet.WebPages
Upvotes: 4
Reputation: 6178
I have fetch same problem for MVC5.
At First Check your System.Web.WebPages assembly from Reference of your project.
For me, I add a reference of version 2.0.0.0. but my web.config file reference it from
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
and I change it to
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
it works for me in MVC5.
Please check highlighted section in my attachment for more clearance.
Upvotes: 1
Reputation: 486
Worked for me:
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution
Browse
Search for "Microsoft.AspNet.WebPages"
Make sure all projects in solution have the latest version.
Upvotes: 16
Reputation: 1030
I had this issue, all I had to do was change the property of the external reference: Specific Version from True to False
After that the project build again.
Upvotes: 1
Reputation: 419
The solution for me was to go to my server and install the Web Pages Version 2 on the server.
Go to http://www.microsoft.com/en-us/download/details.aspx?id=34600
And download the package and run it.
It was as simple as that.
Upvotes: 25
Reputation: 6690
I scratched my head for a while over this problem when I had it. Eventually I noticed that I had the following section in the "runtime" section of my web.config.
<runtime>
. . .
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
. . .
</runtime>
As you can see, this refers to version 2 of the assembly, which doesn't match the following code that you also have in the system.web/compilation/assemblies section of web.config.
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
The actual assembly referenced in References for the project is indeed v1.0.0.0, so I changed the first chunk of code above to the following, which fixed the problem immediately. I'm not sure how the mistake got there in the first place.
<runtime>
. . .
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" />
</dependentAssembly>
. . .
</runtime>
Upvotes: 6
Reputation: 4348
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 1.0.0.0 and a 2.0.0.0. I made sure to add the version 1.0.0.0 one as that was the one that was missing.
Upvotes: 20