WCF .svc file served as plain text in IIS7.5 .NET 4.0 - Not under Default Web Site

折月煮酒 提交于 2019-12-20 07:22:40

问题


FINAL UPDATE: It turns out this was a red-herring due to a compression issue with a DotNetNuke module. I had to add to the PageBlaster DNN module, so this is no longer an issue.

I am deploying a WCF svc file to my live website for the first time and it is rendering/served up to the browser as plain text. It works fine on my dev environment on localhost. You can see the problem here:

http://www.pokerdiy.com/test.svc

The website is running on IIS 7.5.7600.16385 on Windows Server 2008 R2 Version 6.1 SP1 (64 bit) in an Integrated Application pool with .NET 4.0 (I am using Entity Framework 4.2).

UPDATE: On the live server, the site is added as a Website (ie. not under Default Web Site), whereas on my dev environment DotNetNuke is running as a Virtual Directory under the Default Web Site with it's own web.config (which I compared to the one on the live site and is identical).

Interestingly, when I am on the live server and I browse to the test.svc file in the DEfault Web Site then it works (http://localhost/Test.svc) - however, the one under the PokerDIY.com website does not (http://www.pokerdiy.com/test.svc). So it seems as though my Default Web Site is different to the additional websites somehow?

Another interesting thing: I removed all .svc Handler Mappings and now I can get the "HTTP Error 404.3 - Not Found" error. So the Handler Mappings are intercepting it, it's just not doing anything with it! I can get it back to static text by re-adding the .svc Handler Mappings.

After a lot of RTFMing, The first thing I checked was the Handler Mappings as per the MS article: all the svc mappings are there (svc-integrated is at the top as per this article)

I also re-installed WCF as per this article with no difference. Using Fiddler I can see that the Content-Type is "text/html"

What else can I try?

Note: ASMX webservices, ASP.NET files etc. all work fine.

Update: My Hosting Provider suggested I make the directory where the service resides into a Virtual Directory, which I did not have to do on my local machine in Dev. So now it uses the Parent websites appool and at leats it is doing something - it gets a different error. This does not sound correct though - why would it not be handled by the website appool? I moved the .svc into the root (http://www.pokerdiy.com/test.svc) to remove this from the equation).

Other things I have tried: Changing modules runAllManagedModulesForAllRequests="false" to "true" (it is false in my web.config) %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir WCF in IIS 5.1 served as plain text file 404 when running .net 4 WCF service on IIS (no svc file)


回答1:


Make sure you have enabled the Application Server role.




回答2:


My hosting provider says that the Directory ("/framework") under the Website needs to be configured as Virtual Directory and use the parent AppPool.

When I do this the svc does seem to get processed (and I get another set of .NET errors).

However, on my dev environment, the sub folder is NOT a separate virtual directory - does it need to be?




回答3:


Make sure Directory browsing is "disabled" as well



来源:https://stackoverflow.com/questions/8548883/wcf-svc-file-served-as-plain-text-in-iis7-5-net-4-0-not-under-default-web-si

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!