|
i'm trying to do a BinaryWrite to push documents from the server to the user. the code looks like this:
' fileName and filePath come from the quesrystring
Response.Clear
if Not IsNull(InStr(UCase(filePath), ".PDF")) then
Response.ContentType = "application/pdf"
else
Response.ContentType = "application/x-msdownload"
end if
Response.CharSet = ""
fn = Server.MapPath(filePath)
ctFn = "filename=" & fileName
Response.AddHeader "Content-transfer-encoding", "binary"
Response.AddHeader "Content-Disposition","attachment; " & ctFn
Set adoStream = CreateObject("ADODB.Stream")
adoStream.Open()
adoStream.Type = 1
adoStream.LoadFromFile(fn)
Response.BinaryWrite adoStream.Read()
adoStream.Close
Set adoStream = Nothing
Response.End
our Windows application has an IE control which has a page with links to the .ASP script above. the script lives on our server, along with the documents we need to push.
here's the issue:
when the user hits a link in the contained IE instance, and there is already an external IE window open somewhere (outside our app - like, for example, the IE window i'm typing in right now), that IE window will get focus, and will apparently grab the incoming file and pass it onto the OS. for example: if it's downloading a PDF file, that external IE window will jump to the front, sit there, handle the download, and then Acrobat will appear and handle the PDF - the IE page doesn't change at all.
but, if there is no external IE window open anywhere, a new one is created, and it will handle the download. most of the time, that IE window will immediately vanish. but sometimes (maybe with small files only?), that IE will stay up, with an "Action canceled" message on it. the download will still succeed, but that IE window sits there, scaring the user.
so, it looks like the new IE instance gets this attachment, but no HTML, and assumes that it got a failed transfer ?
i'm using IE6.0.
as far as i can tell with Google, a lot of people on the web have reported this exact problem. but nobody's ever posted a solution.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Ok, stupid question time: why, since you're doing all of this in your own app anyway, don't you just use WinInet or such to download the file, rather than relying on IE to "do the right thing"? I mean, the way things have been going, this is all going to change in a year anyway, so even if you do finally find The One Great Hack that lets IE download the file without scaring the user, by next March it'll probably be throwing five or six UAC dialogs in their face and reporting your company to the FTC.
So, uh, yeah - be lazy like the rest of us, override OnBeforeNavigate and do it that way...
|
|
|
|
|
Shog9 wrote: don't you just use WinInet or such to download the file
because i don't write the specs. my spec was : click the link, get the file. not, click the link, invoke the secondary app we installed, get the file.
other sites do this. i know it's possible.
Shog9 wrote:
override OnBeforeNavigate and do it that way
i'm in classic ASP... i haven't tried the ASP.Net way. i can, nobody will care how i implement this (on the server). but there are dozens of examples on the web of people doing pretty much exactly what i've posted here (that's where we got it) - there are tons of examples of people doing the equivalent in ASP.Net, too. it feels like there's just one little flag or something missing, to tell IE how to behave nicely.
linking directly to the file would be nice, but then we run into content-expiration problems, when IE downloads, then deletes, the file before the associated app can get it.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Chris Losinger wrote: not, click the link, invoke the secondary app we installed, get the file.
I thought you were doing this from within an embedded MSHTML control. Does this also happen from IE stand-alone? I've never seen this, but it's certainly possible to get some odd interactions between MSHTML/WebBrowser Ctrl and IE.
Oh, and... you don't have a target attribute on those links, right?
|
|
|
|
|
Shog9 wrote: I thought you were doing this from within an embedded MSHTML control
i am. but unforunately, i can't do anything to change that app, so i can't do the obvious thing: add a download component to it.
Shog9 wrote: Oh, and... you don't have a target attribute on those links, right?
nope.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Do you have access to the source though? Can you see if it's doing anything dodgy with navigation?
Ignore this if i'm obviously on the wrong track, but i've done a few test apps this morning trying to reproduce it, and the only thing remotely similar to what you describe happens when i intercept the browser control's BeforeNavigate2 event and try to perform the navigation myself. Which is why i asked what happens when you try to follow the link from a regular IE window...
|
|
|
|
|
Shog9 wrote: Can you see if it's doing anything dodgy with navigation?
it's just doing a ShellExecute on a URL i provide.
the whole system is something like this:
desktop app starts an embedded IE window and calls out to the server to get a page to display. my code makes that page, so i can put anything i need to on it. the user hits links on that page which do various things: some are handled by the app, some go to other external URLs, some go back to our servers for various things, including documents. for some links, the app intercepts the navigate, does a little pre-processing, then ShellExecutes the link. i've tried these downloading things both ways, with the same result.
in the case of downloading, we have links that look like this:
http://getfile.asp?filename=____&blah=____
getfile.asp is pretty much what i posted above (with some path checks, to make sure nothing gets downloaded that shouldn't).
and, now that i think of it, there probably is a target="_blank" in there. otherwise, the document opens in the embedded IE window, and that's not what we want. i've fixed that bug a couple of times..
Shog9 wrote: and the only thing remotely similar to what you describe happens when i intercept the browser control's BeforeNavigate2 event and try to perform the navigation myself
for me, it's only happening with JPGs. .DOC, .PDF, etc. work OK (the new IE window goes away). but with JPGs i get the Action Canceled page, as soon as the registered JPG-handling app gets the file.
very puzzling.
thanks for spending some time on this.... i spent all of thursday and friday banging away at this wall.
Cleek | Image Toolkits | Thumbnail maker
-- modified at 13:14 Saturday 1st July, 2006
|
|
|
|
|
Chris Losinger wrote: it's just doing a ShellExecute on a URL i provide.
Hah! And here i thought i was trying something totally crazy...
Yeah, that'll do it. Well, the obvious bit at least - it'll open a new window, or re-use an existing one (if one exists and the user's IE settings allow). As to why it leaves a nav canceled page for JPG but not the rest, i don't know for sure... but i suspect it has something to do with how IE sniffs MIME types (which it does, even when you specify x-msdownload ). By the way: you do realize that using ShellExecute will open the user's default browser for all URLs, right? So potentially Firefox or Opera instead of IE...
So now, you really have two choices (short of modifying the app): Send the proper MIME type for JPG files (so they open in the browser rather than a separate app), or change your link to avoid the ShellExecute() call (since if the embedded browser tries to open it directly, it'll just download the file (possibly asking the user whether to ask or save first - again, depending on user and system settings).
|
|
|
|
|
I'm not exactly sure what you want.
Do you want the linked file to always be opened by an external IE window, or for the proper applications to open it?
Why don't you just pass the Response.Content type as "application/octet-stream" therefore when user clicks on the link the user can choose to open your PDF with their preferred reader?
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Edbert P wrote: Why don't you just pass the Response.Content type as "application/octet-stream"
i've tried that. i still get the stray 'Action Canceled' IE window.
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Hi everyone,
The ASP files are stored on web-server and MS Access2K MDBs on another seperate data server ... How can I connect/access database from the one web-server to the other data-server...
Any sugesstions would be of great help.
Thanks in advance.
|
|
|
|
|
Hi,
If Firefox does not support ActiveX controls, then what form does a control have to take in order for Firefox to use it?
For instance, how is the Shockwave Flash player packaged so that Firefox can use it?
Thanks,
Rich
|
|
|
|
|
I have a legacy site that opens a simple page that showing data for a client. On occasion, a query might return multiple clients. I can intercept this in the VBScript in the page before the page draws itself. I would like to then open a new page for each one of the clients. I can't use the Response.Redirect method as that only opens one page. I can't use something like window.open as it tells me that an object is required. Is there a way to open a new window programatically from VBScript?
Thx
Mark Jackson
|
|
|
|
|
I think that following code will be useful for you although I did not get your problem completely.
In VBScript write following code when you want to open new window:
Response.Write("window.open('page.asp')");
Regards,
Ketan.
|
|
|
|
|
That worked perfectly, thanks for the help.
Mark Jackson
Ketan Majumdar wrote:
Response.Write("<script language='javascript'>window.open('page.asp')</script>");
|
|
|
|
|
Can a Singleton pattern have a protected constructor? If so, why/how?
thanks.
shireen
shireen
|
|
|
|
|
The difference between private and protected, is that something that is protected can be access by an inheriting class.
So the reason why the constructor would be protected is that you could inherit the class and use the constructor.
---
b { font-weight: normal; }
|
|
|
|
|
I have 5 boys and they all love to play flash games online. When they fnish playing I look at the screen and there are about 900 pop-ups from them clicking on ads...$$$!
I love da dotNet but I need to learn how to write these things. Does anyone have a recommendation as to where I should begin? I'm looking for a good book, online course, etc. I know absolutely nada about how these things are developed, but I intend to learn!
Any recommendations?
"Half this game is ninety percent mental."
- Yogi Berra
My y and h don't work so well due to my addiction to caffeine and my inability to set a cup down upright.
If you can read thank a teacher, if you can read in English, thank a Marine.
|
|
|
|
|
I believe you would have to get a version of Macromedia Flash and start from there. The Macromedia forums would give you a good start I imagine, but as for later development, I know that Barnes and Nobles bookstores as well as Borders bookstores carry Macromedia Flash development books. I haven't thoroughly looked through one of these books but it should be helpful as well. If you're going to go through Macromedia to get it's program, hope your wallet is full because it can get pricey, their new suite is $1000, or a smaller $165 through a university. If you have more questions, I have a friend who is quite talented in Flash and could give you some pointers if he's willing.
~ Axel Seitz
|
|
|
|
|
Hey all,
I need to force the broswer to raise a file download dialog box for specific files (http://support.microsoft.com/default.aspx/kb/260519[^]).
I have tried to search Google, and I found this link:
http://www.aspfaq.com/show.asp?id=2161[^]
Since I want to use this method (which works all the time - btw) in a dynamic way - where one page (download.asp) serves more then one file - I need query strings.
The problem is that is it unsafe to use when changing download.asp to accept query strings, because users can change the strings to download whatever files they want.
Any other ideas or alternatives will be appreciated.
Much Thanks.
Regards,
Zdr.
-- modified at 9:34 Thursday 29th June, 2006
|
|
|
|
|
Verify that the path that comes in the querystring is in a folder where you allow downloads.
Or store the paths of the downloadable files in a database, and only send the id of the file in the querystring.
---
b { font-weight: normal; }
|
|
|
|
|
Or use session variables.
|
|
|
|
|
That, however, requires that you know what file is going to be downloaded when the previous page is created. If that page is used to select the file, you don't know what file the user will select.
---
b { font-weight: normal; }
|
|
|
|
|
Use linkbuttons or regular buttons and do the Session.Add in the Click event handler.
Obviously this won't work with regular old html anchors or asp hyperlink controls.
|
|
|
|
|
And then do a redirect? Causes another roundtrip to the browser, but it works.
---
b { font-weight: normal; }
|
|
|
|
|