I get the following error when I try to run one of my scaffolded views in mvc 4:
Server Error in '/' Application. There is no build provider registered for the extension '.cshtml'. You can register one in the section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.
The only answers I have found relate to intellisense but my code complies fine and breaks at runtime. This is a strange error as I am not using a class library. There is just one controller that gives this message on all of its views, all other controllers/views work fine.
This solved the problem for me.
Change this in Web.config
<compilation debug="true" targetFramework="4.5.1" optimizeCompilations="true" /> to
<compilation debug="true" targetFramework="4.5.1" optimizeCompilations="false" /> ADDED: when after a few minutes I back web.config to old, the problem not repeated. strange things )
If the solution in Razor Compiler Warning/Errors - ASP.NET MVC 4 did not work by adding the following code to the ROOT web.config
<compilation debug="true" targetFramework="4.0"> <!-- New --> <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies> </compilation> then try restarting Visual Studio. This worked for me, so would suggest that perhaps a Visual Studio bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With