What is the ContentType of Response ?

A

ad

I create a MemoryStream form a dataset:

MemoryStream sm= new MemoryStream();
dsHealth.WriteXml(sm);

I use
Response.Write()
to send this XML MemoryStream as file to client.

What is the ContentType of Response I must set?
 
J

Juan T. Llibre

If you were sending XML to be inserted into HTML, you'd set the ContentType :

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

But, since what you want to do is send a file, not render it, you need to serialize the objects
to a memory stream and then send the bytes in the memory stream buffer over the TCP connection.

See this article for sample code :
http://www.thescripts.com/forum/thread178613.html

There's more sample code at :
http://www.developerfusion.co.uk/show/4415/5/
 
A

ad

Thanks,
I still have a question.
What is the difference if I use
Response.ContentType = "application/xml";
 
E

Egbert Nierop \(MVP for IIS\)

ad said:
Thanks,
I still have a question.
What is the difference if I use
Response.ContentType = "application/xml";

By default, they are the same but in theory, you could (on Windows) bind a
different clsid to them, so when the content type would be application/xml
you could open XmlSpy (for instance) and when it is text/xml IE.
 

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,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top