|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Downloading file from databaseI have build a web page that lists files in a database. When the user
clicks on the file the page streams the file contents to the browser with code like: Response.AppendHeader("Content-Disposition","attachment;filename=" + strFileName); Response.AppendHeader("Content-Length",lLength.ToString()); Response.ContentType = strContentType; Response.BinaryWrite(binData); My problem is that if the file is html or xml, it appears in the browser window. If the file is jpg, text, etc it appears in a seperate application window. The desired behaviour is to always show the document in a seperate window, but I can't write specific code to handle each file type individually. Is it possible to force the file to download a view in a seperate window? Just the correct content type.
I enforce downloading PDF instead of viewing it this way. Show quoteHide quote "Jeremy Chapman" <m*@here.com> schreef in bericht news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl... >I have build a web page that lists files in a database. When the user >clicks on the file the page streams the file contents to the browser with >code like: > Response.AppendHeader("Content-Disposition","attachment;filename=" + > strFileName); > Response.AppendHeader("Content-Length",lLength.ToString()); > Response.ContentType = strContentType; > Response.BinaryWrite(binData); > > My problem is that if the file is html or xml, it appears in the browser > window. If the file is jpg, text, etc it appears in a seperate > application window. The desired behaviour is to always show the document > in a seperate window, but I can't write specific code to handle each file > type individually. Is it possible to force the file to download a view > in a seperate window? > The type is correct. But for some types windows displays them using IE, and
in that case it displays it in the same window as the list of files. If it's in IE, I want it to display in a seperate window. Show quoteHide quote "Edwin Knoppert" <i***@pbsoft.speedlinq.nl> wrote in message news:dm5bfs$ok1$1@azure.qinip.net... > Just the correct content type. > I enforce downloading PDF instead of viewing it this way. > > > "Jeremy Chapman" <m*@here.com> schreef in bericht > news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl... >>I have build a web page that lists files in a database. When the user >>clicks on the file the page streams the file contents to the browser with >>code like: >> Response.AppendHeader("Content-Disposition","attachment;filename=" + >> strFileName); >> Response.AppendHeader("Content-Length",lLength.ToString()); >> Response.ContentType = strContentType; >> Response.BinaryWrite(binData); >> >> My problem is that if the file is html or xml, it appears in the browser >> window. If the file is jpg, text, etc it appears in a seperate >> application window. The desired behaviour is to always show the document >> in a seperate window, but I can't write specific code to handle each file >> type individually. Is it possible to force the file to download a view >> in a seperate window? >> > > Oh, i meant it the other way around, by NOT using the real type like pdf but
that inary, you get the download fialog. But now i see you don't want that. You might consider to open an new window and point to the pdf. But i don't think you'll be able to determine if the pdf get's loaded IN the window or not. So, leave it to the user.. Show quoteHide quote "Jeremy Chapman" <m*@here.com> schreef in bericht news:%23oL8xQU8FHA.2816@tk2msftngp13.phx.gbl... > The type is correct. But for some types windows displays them using IE, > and in that case it displays it in the same window as the list of files. > If it's in IE, I want it to display in a seperate window. > > > "Edwin Knoppert" <i***@pbsoft.speedlinq.nl> wrote in message > news:dm5bfs$ok1$1@azure.qinip.net... >> Just the correct content type. >> I enforce downloading PDF instead of viewing it this way. >> >> >> "Jeremy Chapman" <m*@here.com> schreef in bericht >> news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl... >>>I have build a web page that lists files in a database. When the user >>>clicks on the file the page streams the file contents to the browser with >>>code like: >>> Response.AppendHeader("Content-Disposition","attachment;filename=" + >>> strFileName); >>> Response.AppendHeader("Content-Length",lLength.ToString()); >>> Response.ContentType = strContentType; >>> Response.BinaryWrite(binData); >>> >>> My problem is that if the file is html or xml, it appears in the browser >>> window. If the file is jpg, text, etc it appears in a seperate >>> application window. The desired behaviour is to always show the >>> document in a seperate window, but I can't write specific code to handle >>> each file type individually. Is it possible to force the file to >>> download a view in a seperate window? >>> >> >> > > Hi Jeremy
You just have to put your page stream code in a seperate file, and then link to that file with window.open() or target="_blank", when everything should work just like you want... ;) /Stendal Show quoteHide quote "Jeremy Chapman" <m*@here.com> skrev i en meddelelse news:%23qdT31T8FHA.3804@TK2MSFTNGP14.phx.gbl... >I have build a web page that lists files in a database. When the user >clicks on the file the page streams the file contents to the browser with >code like: > Response.AppendHeader("Content-Disposition","attachment;filename=" + > strFileName); > Response.AppendHeader("Content-Length",lLength.ToString()); > Response.ContentType = strContentType; > Response.BinaryWrite(binData); > > My problem is that if the file is html or xml, it appears in the browser > window. If the file is jpg, text, etc it appears in a seperate > application window. The desired behaviour is to always show the document > in a seperate window, but I can't write specific code to handle each file > type individually. Is it possible to force the file to download a view > in a seperate window? >
Other interesting topics
How to add a small HTML table under a row of a GridView
Application["TotalPlayings"]++ doesn't work Source Control Products??? Correct syntax for an update stored procedure Setting Profile properties for not logged in users Some questions about masterpages. how load one frame before another in aspx page The server tag is not well formed Finding DataKey in GridView DropDownList |
|||||||||||||||||||||||