how to fix error “This type of page is not served.” error when trying to browse on *.cshtml files

Programming, error messages and sample code > ASP.NET
After you published your MVC3/MVC4 to server, you got error message below with a simple .cshtml file

Server Error in '/' Application.
 
This type of page is not served.
 
Description: The type of page you have requested is not served because it has been explicitly forbidden. The extension '.cshtml' may be incorrect. Please review the URL below and make sure that it is spelled correctly.
 
Requested URL: /index.cshtml

That is because you are trying to directly access a Razor page outside of the ~/Views folder while in ASP.NET MVC 4 this is disabled by default. In order to enable it all you have to do is adjust the following setting in your web.config:
<appSettings>
    <add key="webpages:Enabled" value="true" />
</appSettings>