none
NetHttpsBinding as CustomBinding possible? RRS feed

  • Question

  • Hi, I've got a netHttpsBinding that works, but need to add maxPendingAcceps as well as turn off reliable messaging. It is my understanding this requires a customBinding to get access to the necessary properties. Does only one know otherwise or how to convert:

          <netHttpsBinding>
            <binding name="netBind1" maxBufferPoolSize="5242880" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
              <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
              <security mode="TransportWithMessageCredential">
                <transport clientCredentialType="None" />
                <message clientCredentialType="UserName" />
              </security>
              <webSocketSettings transportUsage="WhenDuplex"/>
            </binding>
          </netHttpsBinding>

    /Regards

    Nicklas Norling

    Monday, October 16, 2017 2:43 PM

Answers

  • Hi Nicklas,

    It might be difficult to implement custombinding from netHttpsBinding in web.config.

    In code, we could implement custom binding from system built-in binding like below:

    NetHttpsBinding binding = new NetHttpsBinding();
                binding.ReliableSession.Enabled = false;
                binding.MaxBufferPoolSize = 5242880;
                binding.MaxBufferSize = 2147483647;
                binding.MaxReceivedMessageSize = 2147483647;
                binding.ReaderQuotas.MaxDepth = 2147483647;
                binding.ReaderQuotas.MaxStringContentLength = 2147483647;
                binding.ReaderQuotas.MaxArrayLength = 2147483647;
                binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
                binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
                binding.Security.Mode = BasicHttpsSecurityMode.TransportWithMessageCredential;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                
                binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.WhenDuplex;
                CustomBinding customBinding = new System.ServiceModel.Channels.CustomBinding(binding);
                BindingElementCollection elements = customBinding.Elements;
                foreach (BindingElement be in elements)
                {
                    Type thisType = be.GetType();
                    System.Diagnostics.Debug.WriteLine(thisType);
                    if (be is HttpTransportBindingElement)
                    {
                        HttpTransportBindingElement httpElement = (HttpTransportBindingElement)be;
                        httpElement.MaxPendingAccepts = 100000;
                    }
                }

    I suggest you check whether below code meets your requirement.

    If you insist on generating custom binding in web.config, then you could check the elements in “customBinding.Elements”, and then generate elements one by one in web.config.

    #<customBinding>

    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/custombinding

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 17, 2017 2:54 AM

All replies

  • Hi Nicklas,

    It might be difficult to implement custombinding from netHttpsBinding in web.config.

    In code, we could implement custom binding from system built-in binding like below:

    NetHttpsBinding binding = new NetHttpsBinding();
                binding.ReliableSession.Enabled = false;
                binding.MaxBufferPoolSize = 5242880;
                binding.MaxBufferSize = 2147483647;
                binding.MaxReceivedMessageSize = 2147483647;
                binding.ReaderQuotas.MaxDepth = 2147483647;
                binding.ReaderQuotas.MaxStringContentLength = 2147483647;
                binding.ReaderQuotas.MaxArrayLength = 2147483647;
                binding.ReaderQuotas.MaxBytesPerRead = 2147483647;
                binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
                binding.Security.Mode = BasicHttpsSecurityMode.TransportWithMessageCredential;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
                
                binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
                binding.WebSocketSettings.TransportUsage = WebSocketTransportUsage.WhenDuplex;
                CustomBinding customBinding = new System.ServiceModel.Channels.CustomBinding(binding);
                BindingElementCollection elements = customBinding.Elements;
                foreach (BindingElement be in elements)
                {
                    Type thisType = be.GetType();
                    System.Diagnostics.Debug.WriteLine(thisType);
                    if (be is HttpTransportBindingElement)
                    {
                        HttpTransportBindingElement httpElement = (HttpTransportBindingElement)be;
                        httpElement.MaxPendingAccepts = 100000;
                    }
                }

    I suggest you check whether below code meets your requirement.

    If you insist on generating custom binding in web.config, then you could check the elements in “customBinding.Elements”, and then generate elements one by one in web.config.

    #<customBinding>

    https://docs.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/wcf/custombinding

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, October 17, 2017 2:54 AM
  • Thanks so much, that's great info!

    /Nicke

    Tuesday, October 17, 2017 6:34 AM