配置WCF休息web.config

时间:2014-03-20 07:04:59

标签: c# wcf rest

这就是我的web.config看起来的样子,当我尝试POST对其中一个方法的请求时,我收到了错误的请求错误。我将文件内容作为HTTP POST的参数发送到我的方法。我使用base64编码发送文件。当参数内容变大时,即对于大文件,我收到错误的请求错误。

我在cs文件中放了断点,我发现该方法根本没有被调用。可能是什么问题?我添加了maxStringContentLength值,但仍无用。

我是新手,所以我不太确定web.config文件应该如何包含。

以下是web.config看起来的样子:

 <?xml version="1.0"?>
    <configuration>
      <configSections>
        <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
      </configSections>
      <connectionStrings>

      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.0" />
      </system.web>
      <hibernate-configuration configSource="nhibernate.config"></hibernate-configuration>
      <system.net>
        <mailSettings>
          <smtp>

          </smtp>
        </mailSettings>
      </system.net>

      <appSettings>
        <add key="allowlog" value="1" />
      </appSettings>

      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true">
          <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </modules>
      </system.webServer>

      <system.serviceModel>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
        <standardEndpoints>
          <webHttpEndpoint>
            <!-- 
                Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
                via the attributes on the <standardEndpoint> element below
            -->
            <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false" defaultOutgoingResponseFormat ="Json"/>
          </webHttpEndpoint>
        </standardEndpoints>

        <behaviors>

          <endpointBehaviors>

            <behavior name="webHttpBehavior">

              <webHttp defaultOutgoingResponseFormat="Json"/>

            </behavior>
            <behavior name="allowmaxfilesize">
              <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
            </behavior>
          </endpointBehaviors>

        </behaviors>
        <bindings>
          <webHttpBinding>
            <binding name="jsonp" crossDomainScriptAccessEnabled="true" />
            <binding name="test" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" transferMode="Streamed"  openTimeout="00:25:00" closeTimeout="00:25:00" sendTimeout="00:25:00" receiveTimeout="00:25:00" maxBufferSize="2147483647">
              <readerQuotas maxDepth="64"
                     maxStringContentLength="2147483647"
                     maxArrayLength="2147483647"
                     maxBytesPerRead="2147483647"
                     maxNameTableCharCount="2147483647"/>
            </binding>
          </webHttpBinding>
          <basicHttpBinding>
            <binding name="IncreasedTimeout" transferMode="Streamed" maxReceivedMessageSize="4294967296" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" sendTimeout="00:25:00" openTimeout="00:25:00" receiveTimeout="00:10:00" closeTimeout="00:25:00">
              <readerQuotas
          maxArrayLength="2147483647"
              maxBytesPerRead="2147483647"
              maxDepth="2147483647"
              maxNameTableCharCount="2147483647"
          maxStringContentLength="2147483647" />

            </binding>

          </basicHttpBinding>
        </bindings>
        <services>

          <service name="Service1">

            <endpoint address="" behaviorConfiguration="webHttpBehavior" binding="webHttpBinding"

            bindingConfiguration="test" contract="IService1" />

          </service>

        </services>
      </system.serviceModel>

    </configuration>

0 个答案:

没有答案