Send file

  • Thread starter Thread starter Franck Diastein
  • Start date Start date
F

Franck Diastein

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
 
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)

| 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
 
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...
 
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)

| 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)
| >
| > | > | 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
| >
| >
 
Back
Top