locked
WCF response adds newline characer RRS feed

  • Question

  • User-1835425756 posted

    Hello,

    i am new to the wcf service.

    i generate the image url as below in the service contract as below:

     lstScoreCardMessages[i].Description = String.Format("<img src=\"{0}/{1}/{2}\"/>", messagepath, clientid, imagename); 

    which is actually generate following image url html code as below:

    <img src="http://xyz.com/abc/5/abc_107.jpg"/>

    but when i test the wcf response in the wcftestclient.exe, i got the following result:

    <img src=\"http://xyz.com/abc/5/abc" +
        "_107.jpg\"/>

    for this reason the image is not shown properly in the client side when html render.

    Can you please help me out from the above issue.

    Thanks in the advance.


    Tuesday, August 6, 2013 1:33 AM

Answers

  • User-646145796 posted

    Hi,

    which is actually generate following image url html code as below:
    <img src="http://xyz.com/abc/5/abc_107.jpg"/>

    in code-behind we get the string as above . but when we input to the aspx page we will get the

    <img src="http://xyz.com/abc/5/abc_107.jpg"/>

    I use two way input it to aspx page

      Response.Write("<img src=\"http://xyz.com/abc/5/abc_107.jpg\"/>");

    or

      Label1.Text = ("<img src=\"http://xyz.com/abc/5/abc_107.jpg\"/>");

    I get the picture in page .

    Best Regards

    Jambor


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2013 11:05 PM

All replies

  • User220959680 posted

    String.Format("<img src=\"{0}/{1}/{2}\"/>", messagepath, clientid, imagename);
    <img src=\"http://xyz.com/abc/5/abc" + "_107.jpg\"/>

    Above is String format issue rather than WCF handling the strings.

    Change to 

    String.Format("<img src="{0}/{1}/{2}"/>", messagepath, clientid, imagename);

    Let us know further issues.

    Tuesday, August 6, 2013 5:05 AM
  • User-1835425756 posted

    Thank you for your support,

    i tried your solution, as follows:

    String.Format("<img src="{0}/{1}/{2}"/>", messagepath, clientid, imagename);

    but it gives me syntax error in c#, so i changed to following:

    lstScoreCardMessages[i].Description = String.Format("<img src='{0}/{1}/{2}'/>", messagepath, clientid, imagename); 

    but the wcf response is as follows:
    in xml version:

    <a:Description>&lt;img src='D:\Projects\abc\M/2/age117.jpg'/&gt;</a:Description>

    in formatted version:

    "<img src=\"http://abc.com/M/2/age" +
        "117.jpg\"/>"


    i required the wcf response as follows in the xml version:

    <a:Description><![CDATA[<img alt="" src="http://abc.com/M/5/age_107.jpg" />]]>

    so that the html render in the WP8 App html browser, as an html image tag, and it is visible.




     

    Tuesday, August 6, 2013 6:32 AM
  • User-646145796 posted

    Hi,

    which is actually generate following image url html code as below:
    <img src="http://xyz.com/abc/5/abc_107.jpg"/>

    in code-behind we get the string as above . but when we input to the aspx page we will get the

    <img src="http://xyz.com/abc/5/abc_107.jpg"/>

    I use two way input it to aspx page

      Response.Write("<img src=\"http://xyz.com/abc/5/abc_107.jpg\"/>");

    or

      Label1.Text = ("<img src=\"http://xyz.com/abc/5/abc_107.jpg\"/>");

    I get the picture in page .

    Best Regards

    Jambor


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, August 7, 2013 11:05 PM