472,102 Members | 2,107 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 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 1718
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Fatih BOY | last post: by
reply views Thread by zhimin | last post: by
4 posts views Thread by ad | last post: by
9 posts views Thread by eswanson | last post: by
3 posts views Thread by =?Utf-8?B?SHVnaA==?= | last post: by
reply views Thread by leo001 | last post: by

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.