开发者

After upgrade, responses are text/html instead of text/xml

开发者 https://www.devze.com 2023-01-30 13:16 出处:网络
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

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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号