locked
webHttp request returns double escaped NewLine RRS feed

  • Question

  • I have a WCF-service which returns a string containing NewLines. The service is deployed to azure.

    The returned string looks good if I use wsHttp-binding. The NewLine is correctly escaped as '\r\n' and displays with proper line breaks.

    If I use the same service via webHttp-binding with WebRequest, the returned string contains double-escaped like '\\r\\n'.

    I checked numerous variants of <globalisation> in <system.web> and also in the webHttp-behaviour and its defaultOutgoingResponseFormat.

    The same scenario works fine when I deploy it to a onPrem VM.


    Thomas Steiner

    Friday, November 20, 2020 4:24 PM

All replies

  • forum migrated to mentioned below link please use this

    https://docs.microsoft.com/en-us/answers/index.html

     hope answer the question if issue resolve please accept answer

    Friday, November 20, 2020 7:59 PM
  • Can you provide your server code and configuration files?

    You can visit the Microsoft Q&A WCF to find answers to your technical questions about WCF.

    Monday, November 23, 2020 8:07 AM
  • The function is: public async Task<string> GetFormattedAddress(string licenseKey, string language)

    It returns Address.Name + Environment.NewLine

    This is the description in the dataContract:

    [OperationContract]
    [FaultContract(typeof(ServiceExceptionDTO))]
    Task<string> GetFormattedAddress(string licenseKey, string language);


    This is in the config in Azure web-app:

    <system.web>
    <compilation debug="false"/>
    <customErrors mode="On"/>
    <httpRuntime targetFramework="4.7"/>
    <globalization
    fileEncoding="Windows-1252"
    enableClientBasedCulture="false"
    enableBestFitResponseEncoding="true"
    requestEncoding="utf-8" 
    responseEncoding="utf-8" 
    responseHeaderEncoding="utf-8"/>
    </system.web>

    <bindings>
    <webHttpBinding>
    <binding 
    name="EndpointBindingHttp" 
    maxBufferPoolSize="209715200" 
    maxReceivedMessageSize="209715200" 
    maxBufferSize="209715200" 
    writeEncoding="utf-8">
    <security mode="Transport">
    <transport 
    clientCredentialType="InheritedFromHost" 
    proxyCredentialType="None" realm=""/>
    </security>
    </binding>
    </webHttpBinding>
    </bindings>

    <behaviors>
    <serviceBehaviors>
    <behavior name="ServiceBehaviorAnonymous">
    <CallWrapper/>
    <serviceDebug includeExceptionDetailInFaults="true"/>
    <serviceThrottling 
    maxConcurrentCalls="10000" 
    maxConcurrentSessions="10000" 
    maxConcurrentInstances="10000"/>
    <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
    </behavior>
    </serviceBehaviors>
     
    <endpointBehaviors>
    <behavior name="EndpointBehaviorHttp">
    <webHttp 
    defaultBodyStyle="WrappedRequest" 
    automaticFormatSelectionEnabled="true" 
    defaultOutgoingResponseFormat="Json"/>
    </behavior>
    </endpointBehaviors>
    </behaviors>

    <service 
    name="Test.Service.ProcessLogic.TestService" 
    behaviorConfiguration="ServiceBehaviorAnonymous">
    <endpoint 
    address="Rest" 
    binding="webHttpBinding" 
    bindingConfiguration="EndpointBindingHttp" 
    behaviorConfiguration="EndpointBehaviorHttp"
    contract="Test.Service.ServiceContracts.ITestServiceBase"/>
    </service>



    Thomas Steiner

    Monday, November 23, 2020 8:48 AM