ASP.NET Web Pages: Fixes for Common Problems

If you get the error:
C# and Razor - The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect

You can try one or more of the followings:

1. Add a "Web.config" file with the following content:

<?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="webPages:Version" value="2.0"/> </appSettings> <system.web> <customErrors mode="Off"/> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.webServer> <directoryBrowse enabled="true" /> </system.webServer> </configuration>

2. In WebMatrix, click the Site workspace, and then in the tree-view click Settings.
(a) In the Select .NET Framework Version list, select .NET 4 (Integrated).
(b) Try to update ASP.NET Web Pages to the latest version.

3. If you run into this error for your hosted site or you have a bin folder containing some DLLs then Choose the folder of your site and convert it to application

In Somee.com/Filer Manger: Click the entry with your site name under Web Sites then choose the Applications option immediately below the site name. Finally choose the folder of interest and click on Convert to Application button.
Note: For Somee.com, the basic Razor examples will work fine even if the "bin" folder is removed thus there is no need for the above.

4. You can browse here for more troubleshooting info.