0

I have several projects that I just upgraded from Visual Studio 2003 and ASP.NET v1 to Visual Studio 2008 and ASP.NET v2. I am explicitly setting a type of "text/xml", and that used to be fine, browsers would render it as xml and IE would even put the cute little +/- signs next to each tag. After the upgrade, IE is rendering only the element content and is ignoring all the tags as if the content was html.

   Response.ContentType = "text/xml";
   String resp = "<soap:Envelope>...blah, blah, lots of xml...</soap:Envelope>\n";
   Response.Write(resp);

I did the upgrades because someone (literally) hosed down our server and it had to be rebuilt, so in the process, we went from IIS 5.1 to IIS 6.0.

Anyone know how to fix this problem? TIA.

1 Answer 1

2

You should do the following before writing the content:

Response.Buffer = true;
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "text/xml";

Then after you have written your XML data into the response, just call Response.End(); to make sure nothing else is being added / changed.


EDIT1: Let's try the following:

Add the line <?xml version='1.0' encoding='UTF-8'?> before you start the string "<soap:Envelope>..."

If that still doesn't get it working, then my last shot is to change the content type to application/soap+xml

2
  • I tried this, but I'm still getting "Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error <all the content>" Dec 10, 2010 at 21:15
  • Didn't work, but it got me along the way to finding out what was wrong. Thanks! Jan 21, 2011 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.