By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,763 Members | 1,641 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,763 IT Pros & Developers. It's quick & easy.

Displaying File name on a fetcher page

P: n/a
Hi all,

I have a file retrieved from a database and I want to return it over a web
page.

I currently have an ASPX page (Download.aspx) with code similar to the
following in Page_Load():

...
string file = Request["file"];byte[] fileData = this.getFile(file); // this
fetches the file's data, to be writtenResponse.ContentType =
"application/octet-stream"
Response.AppendHeader("Content-Disposition", "filename=" & file);
Response.AppendHeader("Content-Length",
fileData.Length);Response.BinaryWrite(file);Respon se.Flush();...I can invoke
this as http://localhost/FetchFile/Download....MyFile.docThis code
works perfectly and returns the file with a download prompt.The problem that
I do have, is that the page shows it's own filename as the title.While this
is not an issue for download links, this page is also indexed, and the
results display a meaningless "Download.aspx" as the result.Adding
"Response.Write("<TITLE>" + file + "</TITLE");also doesn't work, as it gets
mixed up with the file contents, and basically corrupts it.I also tried
setting the page as the default page for the site, so files can be
downloaded ashttp://localhost/FetchFile/?file=MyFile.doc, but then it
returns "FetchFile" as the title.Is there a way of forcing the page's title
to be something I want?I'd appreciate any insight on this.Thanks in
advance,Rukmal.
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Rukmal Fernando" <ru*************@yahoo.com> wrote in message
news:O0**************@TK2MSFTNGP12.phx.gbl...
Hi all,

I have a file retrieved from a database and I want to return it over a web
page.

I currently have an ASPX page (Download.aspx) with code similar to the
following in Page_Load():

...
string file = Request["file"];byte[] fileData = this.getFile(file); // this fetches the file's data, to be writtenResponse.ContentType =
"application/octet-stream"
Response.AppendHeader("Content-Disposition", "filename=" & file);
Response.AppendHeader("Content-Length",
fileData.Length);Response.BinaryWrite(file);Respon se.Flush();...I can invoke this as http://localhost/FetchFile/Download....MyFile.docThis code
works perfectly and returns the file with a download prompt.The problem that I do have, is that the page shows it's own filename as the title.While this is not an issue for download links, this page is also indexed, and the
results display a meaningless "Download.aspx" as the result.Adding
"Response.Write("<TITLE>" + file + "</TITLE");also doesn't work, as it gets mixed up with the file contents, and basically corrupts it.I also tried
setting the page as the default page for the site, so files can be
downloaded ashttp://localhost/FetchFile/?file=MyFile.doc, but then it
returns "FetchFile" as the title.Is there a way of forcing the page's title to be something I want?I'd appreciate any insight on this.Thanks in
advance,Rukmal.


What happens if you use:

Content-Disposition: attachment; filename=<file>

?
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.