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

Send file

Hi,

I'm trying to send a file to the browser with Response.Write, and it
works great.

The problem (I guess...) is that the code that sends the file is in a
class, and whan I load aspx file using the downloading method, I have
the request for file saving in my browser (and I can save the file), but
the aspx's content isn't loaded...

I'v been googling and have seen a way to do creating another
HttpResponse object, but I can't manage to make it work...

Any idea ?

TIA
Nov 19 '05 #1
4 1784
you cannot return both a download file and an html page (or redirect). the
browser makes a request, look at the response (only one) and makes a
decision:

1) the status is 401 - try again with creditinals
2) status not 200 - display error
3) a redirct is sent - request the new url
4) the content type is supported by a plugin - load the plugin - give the
plugin the url
5) the content type is supported by the browser - render it
6) the content type is not supported by the browser - give user option to
save it.

-- bruce (sqlwork.com)

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
| Hi,
|
| I'm trying to send a file to the browser with Response.Write, and it
| works great.
|
| The problem (I guess...) is that the code that sends the file is in a
| class, and whan I load aspx file using the downloading method, I have
| the request for file saving in my browser (and I can save the file), but
| the aspx's content isn't loaded...
|
| I'v been googling and have seen a way to do creating another
| HttpResponse object, but I can't manage to make it work...
|
| Any idea ?
|
| TIA
Nov 19 '05 #2
Buy I have seen many sites with a button ala "Export this", and the
pages reloads, and when it's loaded I have a window asking me where to
store the file...

bruce barker wrote:
you cannot return both a download file and an html page (or redirect). the
browser makes a request, look at the response (only one) and makes a
decision:

1) the status is 401 - try again with creditinals
2) status not 200 - display error
3) a redirct is sent - request the new url
4) the content type is supported by a plugin - load the plugin - give the
plugin the url
5) the content type is supported by the browser - render it
6) the content type is not supported by the browser - give user option to
save it.

-- bruce (sqlwork.com)

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:eC**************@TK2MSFTNGP09.phx.gbl...
| Hi,
|
| I'm trying to send a file to the browser with Response.Write, and it
| works great.
|
| The problem (I guess...) is that the code that sends the file is in a
| class, and whan I load aspx file using the downloading method, I have
| the request for file saving in my browser (and I can save the file), but
| the aspx's content isn't loaded...
|
| I'v been googling and have seen a way to do creating another
| HttpResponse object, but I can't manage to make it work...
|
| Any idea ?
|
| TIA

Nov 19 '05 #3
they open a new window in javascript that requests the download. you have to
be careful with this approach (posting and opening) as if the script to open
the window is inline (from the postback), then popup blockers blockit.

-- bruce (sqlwork.com)

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:ON**************@tk2msftngp13.phx.gbl...
| Buy I have seen many sites with a button ala "Export this", and the
| pages reloads, and when it's loaded I have a window asking me where to
| store the file...
|
| bruce barker wrote:
| > you cannot return both a download file and an html page (or redirect).
the
| > browser makes a request, look at the response (only one) and makes a
| > decision:
| >
| > 1) the status is 401 - try again with creditinals
| > 2) status not 200 - display error
| > 3) a redirct is sent - request the new url
| > 4) the content type is supported by a plugin - load the plugin - give
the
| > plugin the url
| > 5) the content type is supported by the browser - render it
| > 6) the content type is not supported by the browser - give user option
to
| > save it.
| >
| > -- bruce (sqlwork.com)
| >
| > "Franck Diastein" <fd*******@euskaltel.net> wrote in message
| > news:eC**************@TK2MSFTNGP09.phx.gbl...
| > | Hi,
| > |
| > | I'm trying to send a file to the browser with Response.Write, and it
| > | works great.
| > |
| > | The problem (I guess...) is that the code that sends the file is in a
| > | class, and whan I load aspx file using the downloading method, I have
| > | the request for file saving in my browser (and I can save the file),
but
| > | the aspx's content isn't loaded...
| > |
| > | I'v been googling and have seen a way to do creating another
| > | HttpResponse object, but I can't manage to make it work...
| > |
| > | Any idea ?
| > |
| > | TIA
| >
| >
Nov 19 '05 #4
I will try your approach,

Thank you

bruce barker wrote:
they open a new window in javascript that requests the download. you have to
be careful with this approach (posting and opening) as if the script to open
the window is inline (from the postback), then popup blockers blockit.

-- bruce (sqlwork.com)

"Franck Diastein" <fd*******@euskaltel.net> wrote in message
news:ON**************@tk2msftngp13.phx.gbl...
| Buy I have seen many sites with a button ala "Export this", and the
| pages reloads, and when it's loaded I have a window asking me where to
| store the file...
|
| bruce barker wrote:
| > you cannot return both a download file and an html page (or redirect).
the
| > browser makes a request, look at the response (only one) and makes a
| > decision:
| >
| > 1) the status is 401 - try again with creditinals
| > 2) status not 200 - display error
| > 3) a redirct is sent - request the new url
| > 4) the content type is supported by a plugin - load the plugin - give
the
| > plugin the url
| > 5) the content type is supported by the browser - render it
| > 6) the content type is not supported by the browser - give user option
to
| > save it.
| >
| > -- bruce (sqlwork.com)
| >
| > "Franck Diastein" <fd*******@euskaltel.net> wrote in message
| > news:eC**************@TK2MSFTNGP09.phx.gbl...
| > | Hi,
| > |
| > | I'm trying to send a file to the browser with Response.Write, and it
| > | works great.
| > |
| > | The problem (I guess...) is that the code that sends the file is in a
| > | class, and whan I load aspx file using the downloading method, I have
| > | the request for file saving in my browser (and I can save the file),
but
| > | the aspx's content isn't loaded...
| > |
| > | I'v been googling and have seen a way to do creating another
| > | HttpResponse object, but I can't manage to make it work...
| > |
| > | Any idea ?
| > |
| > | TIA
| >
| >

Nov 19 '05 #5

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

Similar topics

2
by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none...
0
by: zhimin | last post by:
Hi, I'm writing a program to send large file(100m) through dotnet using TCPListener & TCPClient, I'm sending the file with a ask and response loop: 1. Client send a flag 1 to server indicate it...
4
by: ad | last post by:
I want to send a DataSet to WebService, but the DataSet if too huge(there about 50000 records, and 50 fields every record). My solution is 1.save the DataSet as XML file, 2.zip the XML file. 3....
9
by: eswanson | last post by:
I have a web page I need to post a file plus some other fields to it. How can I do this from a asp.net page. I know I can send individual fields to the other page, but how do I send a file to the...
1
by: Kees | last post by:
Hi there, Im having a bit of trouble with a logfile I use to put logevents in with a streamwriter, after I have written in this file I want to send the file as a mailattachment with smtp. This...
3
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi There, I use follow code to send email inside VB.NET 2005. It does not work well. Error message of "Failure sending email" would occue. However, email was sent out sometimes. I am confused...
1
by: remya1000 | last post by:
how to send a .txt file to a printer. after creating a .txt file i need to send that .txt file to a printer.using vb.net and while sending that file to printer i need to tell, which printer i need...
4
by: gvijayaratnam | last post by:
Hi All, I have a fn prototype as follows void print ( char *Buffer, usigned long bufferSize, int chunkSize ); This fn will accept binary file buffer and the buffer size and the chunk size,...
2
by: SvenV | last post by:
I based my program on the asynchronous client/server example on msdn. There weren't too many modifications to the original code. I just created some extra code to response to different messages. F.e....
1
by: deepaks85 | last post by:
Dear All, I want to send some data through a form with Multiple attachment in an HTML Format. I have tried it but it is not working for me. I am able to send data without attachment but with the...
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: 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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.