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 IIS, main domain and sub-domain have their own application pool. The 'X' sub directory of the main domain has been converted to application and cshtml pages are working. We tried to accomplish the same process, but we have the following error :
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 :
On IIS manager (Win + R and copy %systemroot%\system32\inetsrv\iis.msc)
On the directory in the tree on the left (\Sites\Main_domain\sub_directory
List item Right click on it and I chose "Convert to Application"