I've been tearing my hairs out over this one. Found many similar questions on the internet, but none had an answer that seems to help me.
<div class="post-text" itemprop="description">
I just keep on getting "Directory Listing Denied" when opening the website, and "This type of page is not served" when requesting a specific .cshtml file.
What I do is the following:
In Visual Studio 2010, I select File > New Web Site > ASP.NET Web Site (Razor)
I published the site to C:\inetpub\wwwroot\WebSite.
In IIS7 on my development machine (Windows 7), I converted the published folder to an application, and set the application pool to "ASP.NET v4.0".
Testing localhost/website, everything works fine.
Then I copied the whole folder to the remote machine, which runs Windows Server 2003 and IIS 6.
In IIS6, I created an application of the folder, and assigned a .NET 4 application pool.
When I open the website, I get a "Directory Listing Denied" error message.
When I try to open the Default.cshtml file, I get a "This type of page is not served".
It seems to me that all the required DLLs are included in the Bin folder (included by the "Add Deployable Assemblies" option):
Microsoft.Web.Infrastructure
NuGet.Core
System.Web.Helpers
System.Web.Razor
System.Web.WebPages
System.Web.WebPages.Administration
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
WebMatrix.Data
WebMatrix.WebData
The .NET versions reported on the "This type of page is not served" error page are: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272.
I copied my Razor site from IIS 7 over to IIS 6 and it worked without issue. I do have a few things you should check.
First of all, in IIS 6 the ASP.Net framework version is set at the site level and not the application pool level although an application pool can only run one version of the framework. Make sure you check the properties of the site -> ASP.NET tab to see
what version of the framework that the application extensions are mapped to. Don't forget that if you change the framework version through this tab that it effectively recycles all of the sites on the server so use it with caution.
Secondly, while I didn't have to do this, you might want to look at adding a wildcard mapping:
Hi Rick thanks for the reply! I am sorry, I had email notification turned off, so I didn't see it until now...
The ASP.NET framework version is already set to 4.0.30319 at the site level (in addition to the application level). (I think this was confirmed by the "This type of page is not served" error page which also mentioned ASP.NET version 4.0.30319?)
Also, a wildcard application map is set up to "c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll", with verification turned off. This is both at the site level and the application (folder) level.
Note that I have succesfully deployed an ASP.NET MVC 4 web app to the same site. I don't understand why a Web Pages site is causing so much more trouble...
pbb
6 Posts
Unable to deploy Razor Web Site to IIS 6
Nov 02, 2012 10:23 AM|LINK
I've been tearing my hairs out over this one. Found many similar questions on the internet, but none had an answer that seems to help me.
<div class="post-text" itemprop="description">I just keep on getting "Directory Listing Denied" when opening the website, and "This type of page is not served" when requesting a specific .cshtml file.
What I do is the following:
It seems to me that all the required DLLs are included in the Bin folder (included by the "Add Deployable Assemblies" option):
The .NET versions reported on the "This type of page is not served" error page are: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272.
What am I overlooking?
</div>ASP.NET razor web pages
Rick Barber
571 Posts
Re: Unable to deploy Razor Web Site to IIS 6
Nov 02, 2012 02:25 PM|LINK
I copied my Razor site from IIS 7 over to IIS 6 and it worked without issue. I do have a few things you should check.
First of all, in IIS 6 the ASP.Net framework version is set at the site level and not the application pool level although an application pool can only run one version of the framework. Make sure you check the properties of the site -> ASP.NET tab to see what version of the framework that the application extensions are mapped to. Don't forget that if you change the framework version through this tab that it effectively recycles all of the sites on the server so use it with caution.
Secondly, while I didn't have to do this, you might want to look at adding a wildcard mapping:
http://weblogs.asp.net/owscott/archive/2010/07/08/configuring-iis6-for-webmatrix.aspx
Please mark the replies as answers if they help or unmark if they don't.
OrcsWeb: Managed Windows Hosting Solutions
"Remarkable Service. Remarkable Support."
fab777
926 Posts
Re: Unable to deploy Razor Web Pages site to IIS 6
Dec 05, 2012 07:53 AM|LINK
I think you've probably forgot the default page for the website.
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/dc6eb1b4-9028-4308-9935-52b64edfad36.mspx?mfr=true
You've probably miss the mime type
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/cd72c0dc-c5b8-42e4-96c2-b3c656f99ead.mspx?mfr=true
Please 'Mark as Answer' if this post helps you.
Fabrice ZERROUKI
pbb
6 Posts
Re: Unable to deploy Razor Web Site to IIS 6
Dec 05, 2012 08:09 AM|LINK
Hi Rick thanks for the reply! I am sorry, I had email notification turned off, so I didn't see it until now...
The ASP.NET framework version is already set to 4.0.30319 at the site level (in addition to the application level). (I think this was confirmed by the "This type of page is not served" error page which also mentioned ASP.NET version 4.0.30319?)
Also, a wildcard application map is set up to "c:\windows\microsoft.net\framework\v4.0.30319\aspnet_isapi.dll", with verification turned off. This is both at the site level and the application (folder) level.
Note that I have succesfully deployed an ASP.NET MVC 4 web app to the same site. I don't understand why a Web Pages site is causing so much more trouble...
pbb
6 Posts
Re: Unable to deploy Razor Web Pages site to IIS 6
Dec 05, 2012 08:23 AM|LINK
Hi Fabrice, thanks for the reply.
I did as you suggested, added "default.cshtml" to the default documents list, and added a MIME-type "text/html" for .cshtml.
Now, whenever I open the website, I just get to see the literal CSHTML source code of the page. Of course, this is not what is supposed to happen...
fab777
926 Posts
Re: Unable to deploy Razor Web Pages site to IIS 6
Dec 05, 2012 09:12 AM|LINK
Do you have the required files in the /bin directory:
If, yes, maybe a .NET 4 registration problem, so try to run this command:
c:\windows\microsoft.net\framework\v4.0.30319\aspnet_regiis -iru
Please 'Mark as Answer' if this post helps you.
Fabrice ZERROUKI
Rick Barber
571 Posts
Re: Unable to deploy Razor Web Site to IIS 6
Dec 05, 2012 04:20 PM|LINK
Here is a post that you may find helpful in troubleshooting the issue. It gives you some additional things to check:
http://stackoverflow.com/questions/5900066/what-exactly-needs-done-to-iis-6-to-serve-cshtml-pages
Furthermore, here's a Razor troubleshooting guide with more helpful advice:
http://www.asp.net/web-pages/overview/more-resources/aspnet-web-pages-%28razor%29-troubleshooting-guide
Please mark the replies as answers if they help or unmark if they don't.
OrcsWeb: Managed Windows Hosting Solutions
"Remarkable Service. Remarkable Support."