Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can make it by extending host factory. By little modification of code bellow you can pass an additional parameter to WCFServiceHostFactory to set it from Global.asax I have used the classes bellow to always set it to Int32.MaxValue</p> <p>//in Global.asax</p> <pre><code>routes.Add(new ServiceRoute(routePrefix, new WCFServiceHostFactory(), serviceType)); </code></pre> <p>//WCFServiceHostFactory.cs</p> <pre><code>namespace MyServices.MyService { public class WCFServiceHostFactory:WebServiceHostFactory { protected override ServiceHost CreateServiceHost(Type serviceType, Uri[] baseAddresses) { WCFServiceHost host = new WCFServiceHost(serviceType, baseAddresses); return host; } } } </code></pre> <p>//WCFServiceHost.cs</p> <pre><code>namespace MyServices.MyService { public class WCFServiceHost:WebServiceHost { public WCFServiceHost(): base () { } public WCFServiceHost (object singletonInstance, params Uri [] baseAddresses) : base (singletonInstance, baseAddresses) { } public WCFServiceHost(Type serviceType, params Uri[] baseAddresses) : base (serviceType, baseAddresses) { } protected override void OnOpening () { base.OnOpening (); foreach (Uri baseAddress in BaseAddresses) { bool found = false; foreach (ServiceEndpoint se in Description.Endpoints) if (se.Address.Uri == baseAddress) { found = true; ((WebHttpBinding)se.Binding).ReaderQuotas.MaxStringContentLength = Int32.MaxValue;//here you set it and also set it below } if (!found) { if (ImplementedContracts.Count &gt; 1) throw new InvalidOperationException ("Service '"+ Description.ServiceType.Name + "' implements multiple ServiceContract types, and no endpoints are defined in the configuration file. WebServiceHost can set up default endpoints, but only if the service implements only a single ServiceContract. Either change the service to only implement a single ServiceContract, or else define endpoints for the service explicitly in the configuration file. When more than one contract is implemented, must add base address endpoint manually"); var enumerator = ImplementedContracts.Values.GetEnumerator (); enumerator.MoveNext (); Type contractType = enumerator.Current.ContractType; WebHttpBinding binding = new WebHttpBinding(); binding.ReaderQuotas.MaxStringContentLength = Int32.MaxValue; //here also AddServiceEndpoint (contractType, binding, baseAddress); } } foreach (ServiceEndpoint se in Description.Endpoints) if (se.Behaviors.Find&lt;WebHttpBehavior&gt; () == null) se.Behaviors.Add (new WebHttpBehavior ()); // disable help page. ServiceDebugBehavior serviceDebugBehavior = Description.Behaviors.Find&lt;ServiceDebugBehavior&gt; (); if (serviceDebugBehavior != null) { serviceDebugBehavior.HttpHelpPageEnabled = false; serviceDebugBehavior.HttpsHelpPageEnabled = false; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload