473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What is the ContentType of Response ?

ad
I create a MemoryStream form a dataset:

MemoryStream sm= new MemoryStream();
dsHealth.WriteX ml(sm);

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

What is the ContentType of Response I must set?


Jul 14 '06 #1
3 1568
If you were sending XML to be inserted into HTML, you'd set the ContentType :

Response.Conten tType = "text/xml";
Response.Conten tEncoding = 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/


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 español : http://asp.net.do/foros/
=============== =============== =====
"ad" <fl****@wfes.tc c.edu.twwrote in message news:eI******** ******@TK2MSFTN GP03.phx.gbl...
>I create a MemoryStream form a dataset:

MemoryStream sm= new MemoryStream();
dsHealth.WriteX ml(sm);

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

What is the ContentType of Response I must set?


Jul 14 '06 #2
ad
Thanks,
I still have a question.
What is the difference if I use
Response.Conten tType = "applicatio n/xml";


"Juan T. Llibre" <no***********@ nowhere.com¼¶¼g ©ó¶l¥ó·s»D:Ot** ************@TK 2MSFTNGP05.phx. gbl...
If you were sending XML to be inserted into HTML, you'd set the
ContentType :

Response.Conten tType = "text/xml";
Response.Conten tEncoding = 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/


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 español : http://asp.net.do/foros/
=============== =============== =====
"ad" <fl****@wfes.tc c.edu.twwrote in message
news:eI******** ******@TK2MSFTN GP03.phx.gbl...
>>I create a MemoryStream form a dataset:

MemoryStream sm= new MemoryStream();
dsHealth.Write Xml(sm);

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

What is the ContentType of Response I must set?



Jul 14 '06 #3

"ad" <fl****@wfes.tc c.edu.twwrote in message
news:ep******** ******@TK2MSFTN GP05.phx.gbl...
Thanks,
I still have a question.
What is the difference if I use
Response.Conten tType = "applicatio n/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.

"Juan T. Llibre" <no***********@ nowhere.com>
¼¶¼g©ó¶l¥ó·s»D: Ot************* *@TK2MSFTNGP05. phx.gbl...
>If you were sending XML to be inserted into HTML, you'd set the
ContentType :

Response.Conte ntType = "text/xml";
Response.Conte ntEncoding = 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/


Juan T. Llibre, asp.net MVP
aspnetfaq.co m : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
============== =============== ======
"ad" <fl****@wfes.tc c.edu.twwrote in message
news:eI******* *******@TK2MSFT NGP03.phx.gbl.. .
>>>I create a MemoryStream form a dataset:

MemoryStrea m sm= new MemoryStream();
dsHealth.Writ eXml(sm);

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

What is the ContentType of Response I must set?



Jul 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
25029
by: Webgour | last post by:
How do you reproduce this vbscript in C# <% Response.ContentType = "text/plain" response.write "This is text type" %>
3
6778
by: MJ | last post by:
I'm trying to stream the contenttype of "application/x-java-jnlp-file" via asp.net/c#, but the client only sees it as a plain text file. Example: Response.Clear(); Response.ClearHeader(); Response.Contenttype = "application/x-java-jnlp-file" Response.Write(--- jnlp file stuff ---) Response.End();
8
2033
by: Bryan Glennon | last post by:
I have an aspx page. If I set the Response.ContentType = "application/voicexml+xml" then when I load browse to the page it downloads the file and opens .Net Studio to allow me to edit it. It should just display in my browser (as it does if I don't set the ContentType). I have appropriate MIME types set up in IIS (.vxml -->...
0
1170
by: Sean Kraft | last post by:
Hello, I am generating a PDF and writing its bytes to the browser using Response.BinaryWrite(). Before I do this I set the response.contenttype = "application/pdf". When I run in debug I see that the onInit event gets fired twice, causing my PDF to be generated 2x, to be sure that the debugger is not causing the problem, I write out a...
0
5660
by: Microsoft NewsGroups | last post by:
I am creating a TAB delimited file with .XLS extention using the Response.ContentType = "application/ms-excel" method. Normally I would place this on it's own form and delete all the HTML in the ASPX page - otherwise the aspx code gets appended to the end of the file out put to Excel. How do I produce the same output from a page where I cannot...
4
3240
by: Mike Kansky | last post by:
I have an image.aspx that does the following: if request("s")=1 then response.redirect(http://www.domain.com/image1.gif) else response.redirect(http://www.domain.com/image2.gif) end if And then i use it like that in my pages: <img src="images.aspx?s=1">
5
8579
by: David Thielen | last post by:
Hi; I am writing the output of a page directly using IHttpHandler, IRequireSessionState and if it is a text file I set HttpContext.Response.ContentType = "text/plain". But when it displays I get an error telling me it's not a legal xml file. Any ideas? --
1
450
by: rguarnieri | last post by:
Hi!, I'm using Visual Studio 6.0 and I'm trying to open an asp page like a .pdf file, I used Response.ContentType="application/pdf" in my asp page but it doesn't work This is an example: <%@ Language=VBScript %> <%Response.ContentType="application/pdf"%>
1
4066
by: greatvishal | last post by:
Hi, I have a page where I am trying to render a pdf file using response.contenttype = "application/pdf". when the page has rendered, I need to launch a javascript command to launch the window's print dialog box which is usually done using window.print() The issue is because of contenttype not being html, page wouldn't fire the javascript...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8216
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5390
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.