473,387 Members | 1,641 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,387 software developers and data experts.

force download for files using webBrowser control

I am creating a form app that uses a webBrowser control and allows users
to interact with a web hosted application. Users can query the web
app and generate a CSV file that they should be able to save locally.

When the button to save the csv is hit on the page displayed in the
webBrowser control, the CSV file generated by the app opened in a new
webBrowser control and rendered as plain text with comma seperated format.

How can I force the csv file to be dowloaded instead of rendered in a
new window?

Thank You for your help.
Nov 16 '05 #1
2 18694
E,

You can do this by adding a header in the response for the content
disposition. Check out the knowledge base article titled "How To Raise a
"File Download" Dialog Box for a Known MIME Type" located at (watch for line
wrap):

http://support.microsoft.com/default...b;en-us;260519

The code is for the old ASP (it's only one line), but you can easily use
this in .NET (as a matter of fact, I used this for a file download site that
we use here internally).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"E Stafford" <Ih*******@blank.com> wrote in message
news:OI********************@TK2MSFTNGP15.phx.gbl.. .
I am creating a form app that uses a webBrowser control and allows users to
interact with a web hosted application. Users can query the web app and
generate a CSV file that they should be able to save locally.

When the button to save the csv is hit on the page displayed in the
webBrowser control, the CSV file generated by the app opened in a new
webBrowser control and rendered as plain text with comma seperated format.

How can I force the csv file to be dowloaded instead of rendered in a new
window?

Thank You for your help.

Nov 16 '05 #2
Thanks Nicholas,
If I understand right, the example you provided required me to be able
to modify an asp page by adding a response header to the page. I do not
have the ability to do that in this situation. The web application being
accessed through the webbrowser control hosted in my windows form
application is provided by a 3rd party service that our company uses. I
do not have the ability to modify the pages. I have seen articles that
hinted at the idea of rewriting html source but I am not familiar with
the technique. Is there a way to modify the headers before they are read
by the browser control? Would that be an option or can I not alter the
response headers after the browser control recieves it?

Nicholas Paldino [.NET/C# MVP] wrote:
E,

You can do this by adding a header in the response for the content
disposition. Check out the knowledge base article titled "How To Raise a
"File Download" Dialog Box for a Known MIME Type" located at (watch for line
wrap):

http://support.microsoft.com/default...b;en-us;260519

The code is for the old ASP (it's only one line), but you can easily use
this in .NET (as a matter of fact, I used this for a file download site that
we use here internally).

Hope this helps.

Nov 16 '05 #3

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

Similar topics

0
by: Colm Hardiman | last post by:
Hi, I'm writing a custom browser in VB6 using the WebBrowser control. I want to allow web servers to be able to identify that a request is coming from my custom browser rather than an ordinary...
1
by: bhavin | last post by:
I m using webbrowser control in my C# app. My system has IE 6.0. The application is crashing on other machine which has IE 5.0. Any idea why? Any kind of help will be a gr8 favor...
10
by: Selden McCabe | last post by:
I'm trying to display some HTML on a form in a VB.Net project. I've referenced the COM WebBrowser control, and put an instance of it on my form. But during the Form_Load, I'm getting the...
2
by: programmer2004 | last post by:
Hi I have used WebBrowser control and i want to save the entire webpage including pictures etc. i have called ExecWB method of WebBrowser control with OLECMDEXECOPT_DONTPROMPTUSER flag, but it...
5
by: Kruegy Man | last post by:
I have a WinForm application that has a WebBrowser Control. I can navigate to any website fine. I want to store the link addresses in an array to be called back later. For example, if I...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
3
by: cypherkro | last post by:
Hi I have a requirement to automatically download a file using a WebBrowser control without having the "Download File" pop up windows display. I cannot use Webclient!! I am using VS2005, .net2...
6
by: Leon | last post by:
Hi there, I am trying to use the WebBrowser Control in a form which is being started in an own thread by the main form of my application. Unfortunately I am always getting an error in...
0
by: mahendravarma | last post by:
HI, For some reasons, i need to pop up a form containing webbrowser control using windows service. But when it is initializing the web browser control in the form, it is throwing an error in the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.