1

我得到这个错误:

接收对 http://localhost:4936/UserService.svc 的 HTTP 响应时出错。这可能是由于服务端点绑定未使用 HTTP 协议。这也可能是由于服务器中止了 HTTP 请求上下文(可能是由于服务关闭)。有关更多详细信息,请参阅服务器日志。

内部异常:无法从传输连接读取数据:现有连接被远程主机强行关闭

这是我的 Web.config(服务层):

    <?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DellenyEntities" connectionString="metadata=res://*/DellenyModel.csdl|res://*/DellenyModel.ssdl|res://*/DellenyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Delleny;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
    <add name="DellenyModelContainer" connectionString="metadata=res://*/DellenyModel.csdl|res://*/DellenyModel.ssdl|res://*/DellenyModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=Delleny;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5"/>
  </system.web>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicBinding"
                 maxBufferPoolSize="1500000"
                 maxReceivedMessageSize="1500000"
                 maxBufferSize="1500000">
        </binding>
      </basicHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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>
    </behaviors>
    <services>
      <service name="Delleny.Services.UserService">
        <endpoint binding="basicHttpBinding" bindingConfiguration="BasicBinding"
                  contract="Delleny.Model.IUserService" />
      </service>
      <service name="Delleny.Services.BCService">
        <endpoint binding="basicHttpBinding" bindingConfiguration="BasicBinding"
                  contract="Delleny.Model.IBCService" />
      </service>
    </services>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>
4

1 回答 1

0

只需将您的绑定元素替换为如下所示的内容:

<binding name="BasicBinding" maxReceivedMessageSize="2000000" maxBufferSize="2000000" transferMode="Streamed">
     <readerQuotas maxDepth="2000000" maxStringContentLength="2000000" maxArrayLength="2000000" maxBytesPerRead="2000000" maxNameTableCharCount="2000000" />
</binding>
于 2012-12-10T17:41:36.857 回答