Silverlight启用服务和ASP.NET兼容性

时间:2010-01-15 02:14:55

标签: asp.net wcf silverlight

创建启用Silverlight的WCF服务时,以下行放在源文件中 -

[AspNetCompatibilityRequirements(RequirementsMode =
    AspNetCompatibilityRequirementsMode.Allowed)]

它做什么?在线帮助对我来说没有多大意义。

2 个答案:

答案 0 :(得分:3)

在兼容模式下,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.

答案 1 :(得分:0)

我不熟悉此属性,但this document表示:

  

ImpersonationOption是一个三值枚举,就像AspNetCompatibilityRequirementsMode:NotAllowed,Allowed和Required一样。默认值为NotAllowed。如果是允许,您可以从以下配置标志“impersonateCallerForAllOperations”启用服务级别模拟:

<behavior name="MyImp">
    <serviceAuthorization impersonateCallerForAllOperations="false"/>
</behavior>
There are two cases when a service operation is enabled for WCF impersonation:
* The operation has OperationBehavior.Impersonation set to “Required”.
* The operation has OperationBehavior.Impersonation set to “Allowed” and the 
  flag “impersonatedCallerForAllOperations” is set to true.