2012-02-26 18 views

Odpowiedz

15

Jeśli jesteś self-hosting, to część klasy HttpSelfHostConfiguration: MSDN Documentation of the HttpSelfHostConfiguration class

by być stosowany tak:

var config = new HttpSelfHostConfiguration(baseAddress); 
config.MaxReceivedMessageSize = int.MaxValue; 
config.MaxBufferSize = int.MaxValue; 
+0

Dzięki, ale chcę hostować w Asp.Net. Była kiedyś klasa WebApiConfiguration – suing

+5

Hell yeah! 2 GB duże wiadomości FTW !!! – Henrik

+0

To wydaje się być prawdopodobne rozwiązanie, będę musiał przetestować to. Ya right Zasób 2GB w usłudze REST jest szalony. Mamy gruboziarniste usługi, których nienawidzę, czyli ~ 5 mb na wiadomość. Fuj! – suing

14

Możesz zajrzeć do httpRuntime sekcji w web.config aplikacji ASP.NET. Nie są nazwane dokładnie tak samo, ale może istnieć analog do tego, co próbujesz zrobić. Na przykład:

<configuration> 
    <system.web> 
    <httpRuntime maxRequestLength="16384" requestLengthDiskThreshold="16384"/> 
    </system.web> 
</configuration> 

Uwaga: Int32.MaxValue jest 2147483647

+1

jest to dla żądania, a nie odpowiedzi. –

4

pierwszy zrobiłbym tę konfigurację w WCF app.config

<endpoint address ="" binding="basicHttpBinding" bindingConfiguration="basicHttp" contract="AddSubService.IService1"> 
     <!-- 
      Upon deployment, the following identity element should be removed or replaced to reflect the 
      identity under which the deployed service runs. If removed, WCF will infer an appropriate identity 
      automatically. 
     --> 
     <identity> 
     <dns value="localhost"/> 
     </identity> 
    </endpoint> 

    <!-- Metadata Endpoints --> 
    <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
    <!-- This endpoint does not use a secure binding and should be secured or removed before deployment --> 
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
    </service> 

</services> 

<bindings> 
    <basicHttpBinding> 
    <binding name="basicHttp" allowCookies="true" 
      maxReceivedMessageSize="20000000" 
      maxBufferSize="20000000" 
      maxBufferPoolSize="20000000"> 
     <readerQuotas maxDepth="32" 
      maxArrayLength="200000000" 
      maxStringContentLength="200000000"/> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

Następnie spróbuj updaeting odniesienie w stronie ASP.NET który wywołuje WCF w web.config sprawdza, czy punkt końcowy zmienił się na taki sam.

-1

rozwiązać ten problem dokonywania dynamicznego wiązania przed jak ten

BasicHttpBinding bind = new BasicHttpBinding(); 
bind.OpenTimeout = bind.CloseTimeout = bind.SendTimeout = bind.ReceiveTimeout = new TimeSpan(0, 30, 0); 
bind.MaxBufferSize = int.MaxValue; 
bind.MaxReceivedMessageSize = int.MaxValue; 
Powiązane problemy