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?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.msdner.com/forum/thread178613.html
There's more sample code at :
http://www.developerfusion.co.uk/show/4415/5/
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"ad" <flying@.wfes.tcc.edu.twwrote in message news:eIUYNfupGHA.3564@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
>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?
>
>
>
>
>
>
Thanks,
I still have a question.
What is the difference if I use
Response.ContentType = "application/xml";
"Juan T. Llibre" <nomailreplies@.nowhere.comglsD:OtJ9x1wpGH A.3820@.TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
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.msdner.com/forum/thread178613.html
>
There's more sample code at :
http://www.developerfusion.co.uk/show/4415/5/
>
>
>
>
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"ad" <flying@.wfes.tcc.edu.twwrote in message
news:eIUYNfupGHA.3564@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
>>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?
>>
>>
>>
>>
>>
>>
>
>
"ad" <flying@.wfes.tcc.edu.twwrote in message
news:epTOyHxpGHA.3324@.TK2MSFTNGP05.phx.gbl...
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
"Juan T. Llibre" <nomailreplies@.nowhere.com>
glsD:OtJ9x1wpGHA.3820@.TK2MSFTNGP05.phx.g bl...
Quote:
Originally Posted by
>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.msdner.com/forum/thread178613.html
>>
>There's more sample code at :
>http://www.developerfusion.co.uk/show/4415/5/
>>
>>
>>
>>
>Juan T. Llibre, asp.net MVP
>aspnetfaq.com : http://www.aspnetfaq.com/
>asp.net faq : http://asp.net.do/faq/
>foros de asp.net, en espaol : http://asp.net.do/foros/
>===================================
>"ad" <flying@.wfes.tcc.edu.twwrote in message
>news:eIUYNfupGHA.3564@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
>>>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?
>>>
>>>
>>>
>>>
>>>
>>>
>>
>>
>
>
0 comments:
Post a Comment