I have upgraded my site to .Net4 but when requesting a .cshtml file (even if it is pure html without razor) I get a Connection refused error. What's missing?
Update: something changed and now I get a "This type of page is not served" error. I thought .Net4 was all that was required.
Turns out it was simply a matter of having the correct files in the bin dir and an entry in web config. Here's the list of files:
and here's what I needed in web.config:
<compilation>
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
<buildProviders>
<add extension=".cshtml" type="System.Web.WebPages.Razor.RazorBuildProvider, System.Web.WebPages.Razor"/>
</buildProviders>
</compilation>
In addition to .NET 4.0 you need to have the correct .dlls for razor. If you have Visual Studio 2010 SP1 installed you can right click on your web project and select Add Deployable Dependencies. This will copy the required .dlls to you bin folder when you publish your site. If you haven't got SP1 installed you will need to manually configure the .dlls to be published. This post has a good write up of hw to do it.
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