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=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?
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.
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.
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>
Go to menu: "Tools / Nuget Package Manager / Package Manager Console"
run command install-package Microsoft.AspNet.WebPages
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.
I have fetch same problem for MVC5.
At First Check your System.Web.WebPages assembly from Reference of your project.
- If not found, then add by select add reference from project Reference.
- If found, any the check version from Properties of that reference. Then check your project web.config file. May be this two versions are not matching.
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.