- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我需要在我的 WCF 服务中启用 session 。所以我必须:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
当我这样做时,我得到一个异常:
The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the service type with RequirementsMode setting as 'Allowed' or 'Required'
这是我的 web.config:
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
<services>
<service behaviorConfiguration="ExecutionEngine.AccountsBehavior" name="WebService.Services.Accounts">
<endpoint address="" binding="wsHttpBinding" contract="WebService.Services.IAccounts" bindingConfiguration="SafeServiceConf">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="defaultBehavior">
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="ExecutionEngine.AccountsBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true" />
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="WebService.Services.Security.CustomValidator,WebService" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="SafeServiceConf" maxReceivedMessageSize="65536">
<readerQuotas maxStringContentLength="65536" maxArrayLength="65536"
maxBytesPerRead="65536" />
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName" />
</security>
</binding>
<binding name="CrmServiceEndpoint" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" negotiateServiceCredential="false" algorithmSuite="Default" establishSecurityContext="false" />
</security>
</binding>
<binding name="CrmServiceEndpointSSL" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
最佳答案
例子:
namespace WcfService1
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
public class Service1 : IService1
{
关于c# - WCF aspNetCompatibilityEnabled ="true"引发异常(加载失败),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7785344/
我有一个 asp.net 网站。我只想对其中一个 wcf 服务使用 asp.net 兼容模式。 但是,当我这样做时,我最终会收到所有服务的错误消息,因为它会尝试将它用于每一个服务。 我如何有选择地为
我有两个问题: 我在控制台应用程序中托管了一个 wcf 服务,如果我将 ServiceHostingEnvironmentSection.AspNetCompatibilityEnabled 设置为
我需要在我的 WCF 服务中启用 session 。所以我必须: 当我这样做时,我得到一个异常: The service cannot be activated because it does no
我有一个 WCF 服务定义为: [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatib
我有一个 WCF 服务定义为: [ServiceContract] [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatib
我需要从 RESTful WCF 服务中访问 HttpContext.Current。我知道我可以通过在配置中添加以下内容来实现这一点: 并在我的服务中使用以下属性: [AspNetCompatib
我的网站完全是 HTTPS。所以我想在 HTTPS 协议(protocol)中调用 WCFService 但微软说 aspNetCompatibilityEnabled="true"我们不能使用非 h
在我的应用程序的 web.config 中。在某些服务器上,如果我设置 aspNetCompatibilityEnabled=true 我得到“MethodAccessException”。我需要使
我是一名优秀的程序员,十分优秀!