【发布时间】:2010-01-15 02:14:55
【问题描述】:
当您创建启用 Silverlight 的 WCF 服务时,将以下行放在源文件中 -
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
它有什么作用?在线帮助对我来说没有多大意义。
【问题讨论】:
标签: asp.net wcf silverlight
当您创建启用 Silverlight 的 WCF 服务时,将以下行放在源文件中 -
[AspNetCompatibilityRequirements(RequirementsMode =
AspNetCompatibilityRequirementsMode.Allowed)]
它有什么作用?在线帮助对我来说没有多大意义。
【问题讨论】:
标签: asp.net wcf silverlight
在兼容模式下,WCF 服务通过 IHttpHandler 实现使用 HTTP 管道,类似于处理 ASPX 页面和 ASMX Web 服务请求的方式。因此,在以下 ASP.NET 功能方面,WCF 的行为与 ASMX 相同:
* HttpContext: WCF services running in ASP.NET Compatibility Mode can access Current and its associated state.
* File-based authorization: WCF services running in ASP.NET compatibility mode can be secure by attaching file system access control lists (ACLs) to the service’s .svc file.
* Configurable URL authorization: ASP.NET’s URL authorization rules are enforced for WCF requests when the WCF service is running in ASP.NET Compatibility Mode.
* HttpModuleCollection extensibility: Because WCF services running in ASP.NET Compatibility Mode participate fully in the ASP.NET HTTP request lifecycle, any HTTP module configured in the HTTP pipeline is able to operate on WCF requests both before and after service invocation.
* ASP.NET Impersonation: WCF services run using the current identity of the ASP.NET impersonated thread, which may be different than the IIS process identity if ASP.NET impersonation has been enabled for the application. If ASP.NET impersonation and WCF impersonation are both enabled for a particular service operation, the service implementation ultimately runs using the identity obtained from WCF.
【讨论】:
我不熟悉这个属性,但this document 表示:
ImpersonationOption 是一个三值枚举,就像 AspNetCompatibilityRequirementsMode:NotAllowed、Allowed 和 Required。默认值为不允许。如果允许,您可以通过以下配置标志“impersonateCallerForAllOperations”打开服务级别模拟:
<behavior name="MyImp">
<serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
为 WCF 模拟启用服务操作有两种情况: * 该操作的 OperationBehavior.Impersonation 设置为“必需”。 * 该操作的 OperationBehavior.Impersonation 设置为“Allowed”,并且 标志“impersonatedCallerForAllOperations”设置为真。
【讨论】:
ImpersonationOption 的引用或任何与冒充相关的内容。