Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF会话ASP.NET托管问题_Asp.net_Wcf_Iis - Fatal编程技术网

WCF会话ASP.NET托管问题

WCF会话ASP.NET托管问题,asp.net,wcf,iis,Asp.net,Wcf,Iis,我正在构建一个与现有应用程序对话的WCF服务,该应用程序需要访问ASP.NET会话-查看会话的能力是我无法回避的要求 我构建了WCF项目,并在App.config中设置了以下内容: <system.serviceModel> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 这是一个REST服务,因此我的界面启动如下: // NOTE: You can use the "Renam

我正在构建一个与现有应用程序对话的WCF服务,该应用程序需要访问ASP.NET会话-查看会话的能力是我无法回避的要求

我构建了WCF项目,并在App.config中设置了以下内容:

 <system.serviceModel>
     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
这是一个REST服务,因此我的界面启动如下:

// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
[ServiceContract]
public interface ISearchServiceInterface
{

    [OperationContract]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    string LoginToWebService_POST(Altec.Framework.Authorization auth);

    [OperationContract]
    [WebInvoke(BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
    string GetTopLevelFolderName_POST();
服务本身托管在另一个web应用程序中,位于SearchService.svc文件中,该文件具有以下内容:

<%@ServiceHost language=c# Debug="true" Service="Altec.UI.Web.SearchService.SearchService" %>
我将其添加到托管应用程序的web.config中:

  <system.serviceModel>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
我相信我做了所有正确的步骤,但是当我尝试运行web应用程序时,我遇到了以下错误:

System.InvalidOperationException:此服务需要ASP.NET 兼容,并且必须托管在IIS中。在中托管服务 在web.config中打开ASP.NET兼容性的IIS,或设置 AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode 属性设置为非必需的值。在 System.ServiceModel.Activation.AspNetEnvironment.ValidateCompatibilityRequirementsAspNetCompatibilityRequirementsMode 相容性模型 System.ServiceModel.Activation.AspNetCompatibilityRequirementsAttribute.System.ServiceModel.Description.IServiceBehavior.ValidateServiceDescription 说明,ServiceHostBase ServiceHostBase位于 System.ServiceModel.Description.DispatcherBuilder.ValidatedDescriptionServiceDescription 说明,ServiceHostBase serviceHost位于 System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHostServiceDescription 说明,ServiceHostBase serviceHost位于 System.ServiceModel.ServiceHostBase.InitializeRuntime位于 System.ServiceModel.ServiceHostBase.OnBeginOpen位于 System.ServiceModel.ServiceHostBase.OnOpenTimeSpan超时时间为 System.ServiceModel.Channel.CommunicationObject.OpenTimeSpan System.ServiceModel.Channels.CommunicationObject.Open处超时 位于Microsoft.Tools.SvcHost.ServiceHostHelper.OpenServiceInfo 信息


您提到App.config-听起来您的服务是一个WCF服务库,您在IIS下托管。如果是这种情况,则需要将WCF配置部分从App.config复制到承载服务的IIS应用程序的Web.config


库不使用配置文件-它们使用调用应用程序的配置文件。

没错,我这样做了-我将编辑以添加上面完整的web.config。您使用服务文件更新的web.config是应用程序的web.config吗,或者调用服务的应用程序?调用服务的应用程序。将设置放在具有服务文件的IIS应用程序的Web.config中-正是IIS下的应用程序需要将AspNetCompatibilityEnabled设置为True。我这样做了。这仍然是同一个问题。
  <system.serviceModel>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <appSettings>
    <!-- database connection details -->

  </appSettings>
  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>

    <pages>
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit"/>
      </controls>
    </pages>
  </system.web>
  <system.web.extensions>
    <scripting>
      <webServices>
        <jsonSerialization maxJsonLength="1048576"/>
      </webServices>
    </scripting>
  </system.web.extensions>
  <location path="Scripts">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Content">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="jQuery-UI-layout.css">
    <system.web>
      <authorization>
        <allow users="*"/>
      </authorization>
    </system.web>
  </location>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
      <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
      <bindings>
      <wsHttpBinding>
        <binding name="WSHttpBinding_ISearchServiceInterface" 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="Windows" negotiateServiceCredential="true" algorithmSuite="Default"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://vmwarren27dev.altec-wa.com/Altec.UI.Web.Portal/SearchService.svc/WCPService" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ISearchServiceInterface" contract="SearchService.ISearchServiceInterface" name="WSHttpBinding_ISearchServiceInterface">
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
    </client>
    <services>
      <service name="Altec.UI.Web.SearchService.SearchService">
        <endpoint address="RESTService" binding="webHttpBinding" behaviorConfiguration="json" contract="Altec.UI.Web.SearchService.ISearchServiceInterface">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <endpoint address="WCPService" binding="wsHttpBinding" contract="Altec.UI.Web.SearchService.ISearchServiceInterface">
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="True"/>
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="True"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="json">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="AjaxControlToolkit" publicKeyToken="28f01b0e84b6d53e" culture="neutral"/>
        <bindingRedirect oldVersion="0.0.0.0-4.1.51116.0" newVersion="4.1.51116.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>