WCF .svc 文件在 IIS7.5 .NET 4.0 中用作纯文本 - 不在默认网站下

发布于 2024-12-21 21:08:19 字数 2320 浏览 5 评论 0原文

最终更新:事实证明,由于 DotNetNuke 模块的压缩问题,这是一个转移注意力的问题。我必须添加到 PageBlaster DNN 模块,所以这不再是问题。

我第一次将 WCF svc 文件部署到我的 实时网站,并且它正在渲染/提供给浏览器显示为纯文本。它在本地主机上的我的开发环境中运行良好。您可以在这里看到问题:

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

该网站在 Windows Server 2008 R2 版本 6.1 SP1(64 位)上的 IIS 7.5.7600.16385 上运行集成应用程序池.NET 4.0(我使用的是Entity Framework 4.2)。

更新:在实时服务器上,该站点被添加为网站(即不在默认网站下),而在我的开发环境中,DotNetNuke 在默认网站下作为虚拟目录运行,其自己的 web.config (我将其与实时站点上的进行比较,并且是相同的)。

有趣的是,当我在实时服务器上浏览到默认网站中的 test.svc 文件时,它就可以工作了(http ://localhost/Test.svc) - 然而,PokerDIY.com 网站下的那个却没有(http://www.pokerdiy.com/test.svc)。那么我的默认网站似乎与其他网站有所不同?

另一个有趣的事情:我删除了所有 .svc 处理程序映射,现在我可以收到“HTTP 错误 404.3 - 未找到”错误。所以处理程序映射正在拦截它,它只是没有对它做任何事情!我可以通过重新添加 .svc 处理程序映射将其恢复为静态文本。

经过大量 RTFMing 后,我检查的第一件事是按照 MS 文章的处理程序映射:所有 svc 映射都在那里(svc-integrated 位于顶部,如 根据本文

我也重新安装WCF 按照 这篇文章没有什么区别。使用 Fiddler 我可以看到 Content-Type 是“text/html”

我还能尝试什么?

注意:ASMX Web 服务、ASP.NET 文件等都工作正常。

更新:我的托管提供商建议我将服务所在的目录放入虚拟目录中,而我不必在 Dev 中的本地计算机上执行此操作。所以现在它使用父网站应用程序池,至少它正在做一些事情 - 它得到了一个不同的错误。但这听起来不正确 - 为什么网站应用程序池不处理它?我将 .svc 移至根目录(http://www.pokerdiy.com/test.svc) 将其从方程中删除)。

我尝试过的其他事情: 将模块 runAllManagedModulesForAllRequests="false" 更改为“true”(在我的 web.config 中为 false) %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir IIS 5.1 中的 WCF 作为纯文本文件 运行 .net 4 WCF 服务时出现 404在 IIS 上(无 svc 文件)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

忆沫 2024-12-28 21:08:19

确保您已启用应用程序服务器角色。

Make sure you have enabled the Application Server role.

樱&纷飞 2024-12-28 21:08:19

我的托管提供商说网站下的目录(“/framework”)需要配置为虚拟目录并使用父应用程序池。

当我这样做时,svc 似乎确实得到了处理(并且我收到了另一组 .NET 错误)。

但是,在我的开发环境中,子文件夹不是单独的虚拟目录 - 是否需要如此?

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?

堇色安年 2024-12-28 21:08:19

确保目录浏览也被“禁用”

Make sure Directory browsing is "disabled" as well

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文