returning xml from aspx page

S

sam martin

why doesn't IE6 show the response from this page as XML? is the contenttype
wrong?

Basically, i've got an "empty" aspx page (barring the precompiler line <%@
Page language="c#" Codebehind="newssvc.aspx.cs" AutoEventWireup="false"
Inherits="gorlandnet.news.newssvc" %>)

then this in the Page_Load method:

Response.ContentType="text/xml";
Response.ContentEncoding = System.Text.Encoding.UTF8;

Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
Response.Write("<xmldata>");
Response.Write("<newsitem>");
Response.Write("<title>News item</title>");
Response.Write("</newsitem>");
Response.Write("</xmldata>");
Response.End();

what am i doing wrong?

tia

sam martin
 
B

bruce barker

try

Response.ClearHeaders();
Response.Clear();
Response.ContentType="text/xml";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
Response.Write("<xmldata>");
Response.Write("<newsitem>");
Response.Write("<title>News item</title>");
Response.Write("</newsitem>");
Response.Write("</xmldata>");
Response.End();

works for me.

-- bruce (sqlwork.com)
 
T

Tommy

Try this instead:

UTF8Encoding myUTF8 = new UTF8Encoding();
// Put user code to initialize the page here
Response.ContentType="text/xml";
Response.ContentEncoding = myUTF8;

Tommy,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top