473,325 Members | 2,860 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Send XML to browser and force a save as dialog

How do I force an XML document to be downloaded from a web browser to a
client?

The XML document will come ideally from a dataset but if this is not
possible then I can save off the XML document to the server and read it back
in to send to the clients browser. I have somethink like this but am
struggling to send the XML...
With HttpContext.Current.Response
.ClearContent()
.ClearHeaders()
.ContentType = "text/xml"
.AddHeader("Content-Disposition", "attachment; filename=rippo.xml")
.Write(SOMEXMLFILE OR A DATASET)
.End()
End With

Can any one help?

Thanks
Rippo
Nov 21 '05 #1
4 3819
Richard Wilde wrote:
How do I force an XML document to be downloaded from a web browser to
a client?


Change the content-type header to something their browser won't recognise,
like "text/doesntexist". This will force their browser to prompt to download
it.
Nov 21 '05 #2
Ah thank you. That solves half the problem.

I just realised that I did not structure my question.

Can you help me to solve the problem of reading in a XML from disk (or using
a dataset ideally) and finishing my code in the line .Write

With HttpContext.Current.Response
.ClearContent()
.ClearHeaders()
.ContentType = "text/xml"
.AddHeader("Content-Disposition", "attachment; filename=rippo.xml")
.Write(SOMEXMLFILE OR A DATASET)
.End()
End With

Many thanks
Rippo

"Leon Mayne [MVP]" <l.*********@uea.ac.uk> wrote in message
news:Oz***************@TK2MSFTNGP12.phx.gbl...
Richard Wilde wrote:
How do I force an XML document to be downloaded from a web browser to
a client?


Change the content-type header to something their browser won't recognise,
like "text/doesntexist". This will force their browser to prompt to
download
it.

Nov 21 '05 #3
Richard Wilde wrote:
Can you help me to solve the problem of reading in a XML from disk
(or using a dataset ideally) and finishing my code in the line .Write


How about something like:

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Response.Clear()
Response.ContentType = "text/doesntexist"
Response.AddHeader("Content-type", "text/doesntexist")
Response.Write("Some text")
Response.End()
End Sub

Replace the "some text" with the output of your XML object (dataset?)
Nov 21 '05 #4
Leon Mayne [MVP] wrote:
<snip>

Sorry, use this instead:

Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-type", "application/octet-stream")
Response.AddHeader("Content-Disposition", "attachment;
filename=""text.xml""")
Response.Write("Some text")
Response.End()
End Sub
Nov 21 '05 #5

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

Similar topics

14
by: edykstra | last post by:
Hello, If you point your browser to this page, http://prdownloads.sourceforge.net/vnc-tight/tightvnc-1.2.9_x86_viewer.zip?use_mirror=umn the server sends you the HTML page, and very soon...
1
by: Bob Murdoch | last post by:
I've got an intranet application that presents a list of files in sort of a 'central repository' web page. Each file is an href in the form <a href=file://server/share/path/filename.ext>. When...
4
by: Andy Gayton | last post by:
Hey all, It looks like dynamic changes to a html document are only redrawn when the current code snippet comes to an end. For example the following page changes the text in a span, waits for a...
27
by: Curious Angel | last post by:
I have a resume in PDF format and I want anyone who LEFT-OR-RIGHT clicks the link to force the file to be saved, and in any event _not_ opened. Since the PDF will be in his cache in any event, I...
1
by: Piyush Parmar | last post by:
Hi. I would like to know if it's possible to force a dialog box to "expire" after so many seconds? The scenario is that I'm holding various objects in my session. Before it times out, I want...
4
by: DM | last post by:
Is there any way, using a server control, to execute a routine (say, add record to database) and then close the browser window. I'm having a difficult time doing this using a master\detail model...
5
by: Brad | last post by:
In several aspx applications I export crytal reports to pdf, xls and doc files and then the aspx page writes the selected export file to the client browser. This all works with one small quirk: ...
2
by: Sam-Kiwi | last post by:
I've spent the last 6 months developing a pay-per-download website using ASP.NET Users purchase documents and then download them. The intention is that users are only charged for documents...
0
by: Matt Schwartz | last post by:
I have a ASP.NET web application written using VB.NET. I have a data grid, that is sent to the browser as an excel document using the following code Private Sub CreateXLS(ByVal xdatagrid As...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.