cshtml pages don’t work only in a sub-directory of a subdomain. We have a main domain where cshtml works on ‘X’ subdirectory folder, but we have a sub-domain where the root directory is a sub-directory of the main domain and cshtml doesn’t work there. On
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: /test/test.cshtml
This a simple test file, which works on the main domain sub-directory, but not on the sub-domain sub-directory. I think it is the parent domain that blocks, "it has been explicitly forbidden."
On Handler Mappings the extension is active. (Windows Server 2012 R2, IIS 8.5)
The server has the .NET Framework 4 installed. Also the application is running in an application pool that’s configured to use that version of the.NET Framework.
/home/main_domain/X_subdirectory (works cshtml)
/home/main_domain/sub_domain/subdirectory (doesn’t work cshtml)
Do you have any ideas ?
The following code gives to me an Internal error :
<system.webServer> <security> <requestFiltering> <fileExtensions> <remove fileExtension=".cshtml" /> <add fileExtension=".cshtml" allowed="true" /> </fileExtensions> </requestFiltering> </security> </system.webServer>
Adding this to my web.config doesn’t work neither.
<configuration> <appSettings> <add key="webpages:Enabled" value="true" /> </appSettings> </configuration>
The sub directory where it works is configured as a Web Application :
If you directly put cshtml in browser it will not work. You need to put your valid URL which you have configured through routing.
When I put directly the cshtml on the browser works for the other subdirectory. It is a simple .cshtml page.
According to your description, it works fine if you convert it to the application. So I think it is the independent project and you let it in the main project.
If that is the case, since they are independent, you need to convert it to the application.