.net - WCF @ServiceHost 调试 ="true"但 web.config 编译 ="false"

标签 .net wcf debugging web-config release-mode

我一直在查看 MSDN 文档,但没有找到具体的答案。

@ServiceHost 中的 Debug 属性会覆盖 Web.config 的编译属性还是 web.config 属性会覆盖所有属性?

谢谢。

最佳答案

根据:http://msdn.microsoft.com/en-us/library/aa702682.aspx

The ASP.NET HTTP runtime handles ASP.NET requests but does not participate in the processing of requests destined for WCF services, even though these services are hosted in the same AppDomain as is the ASP.NET content. Instead, the WCF Service Model intercepts messages addressed to WCF services and routes them through the WCF transport/channel stack.



除非你在 WCF 的 ASP.NET 兼容模式下运行你的服务。在这种情况下...

Unlike the default side-by-side configuration, where the WCF hosting infrastructure intercepts WCF messages and routes them out of the HTTP pipeline, WCF services running in ASP.NET Compatibility Mode participate fully in the ASP.NET HTTP request lifecycle. In compatibility mode, WCF services use the HTTP pipeline through an IHttpHandler implementation, similar to the way requests for ASPX pages and ASMX Web services are handled.



如果我们接受这个断言,那么我们就知道应该尊重配置继承。

如果你想确定你可能会设置一个测试......

在 ASP.NET 兼容模式下运行的 WCF 服务可以访问 HttpContext.Current 及其关联状态。这意味着您可以询问 IsDebuggingEnabled 属性以查看您是否处于 Debug模式。您还可以使用一些编译器指令(如#if DEBUG)来查看是否到达了代码块。

我很想知道最终的判决是什么。我认为这个问题的关键在于这是否是托管在 IIS 中的 WCF 服务,以及它是否在 AspCompatibility 模式下运行。

关于.net - WCF @ServiceHost 调试 ="true"但 web.config 编译 ="false",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8362603/

相关文章:

c# - 将 cookie 从 CookieContainer 写入 IE cookie 存储

c# - 寻找最佳实践 : Communication between 2 Applications for Filebrowsing and Download

c# - 鼠标停止移动后触发的 WPF 事件

c# - 什么时候使用 PreRender 而不是 PageLoad?

.net - web.config 中的 EF 4.1 代码优先连接字符串

sql - 关于数据库变更的通知

c# - WCF 中的事件委托(delegate)类比

debugging - 使用 gdb 调试时彻底退出 valgrind

java - 附加调试器(使用 eclipse) Play Framework 失败

security - Fiddler 是否为每台机器创建唯一的私有(private)根证书?