|
|
Hi all,
I'm developing an application that allows the user to test a SSH connection. To perform the test, I'm using AJAX to send the request to the server with address, user and password.
What I want to do is to get progress indications to the user while the server makes the necessary test to the connection. I was hoping to get messages to the user like: "Connecting", "Verifying login information", etc.
In my approach, I'm flushing these messages in the server side script (PHP), and wanted to parse them within the "onreadystatechange" function while the "readyState == 3" (loading mode).
The problem is that in IE the "responseText" is empty in this stage but it works fine in Mozilla. As for the "responseXML" property, works in IE but I get a XML parsing error in Mozzila (because the document tag is not yet closed).
Does anyone have any suggestion regarding this or any other approach in order to achieve the same output?
Thank you very much in advance,
|
|
|
|
|
e11even wrote: Does anyone have any suggestion regarding this or any other approach in order to achieve the same output?
Check the status code, if that's cool then just compose an appropriate message client-side. Be aware: last i checked, IE, Fx, Opera and Safari all have subtly different takes on what readyState really means... (don't ask me which ones are compatible just now though) so don't be letting on that it's ok to (for instance) close the browser window until you have absolute confirmation (readyState == 4).
Oh, and if you have a really long-running process, you're probably better off setting things up such that multiple requests/responses are performed to update the status text, rather than relying on a single request pending for x minutes.
|
|
|
|
|
can anyone help me?
i want a page to start a file download without redirecting to blank page.
thanx.
|
|
|
|
|
if you're using PHP, just use
header("location: http://www.domain.com/file.extension");
don't think it's possible in plain ol' HTML though.
~ Axel Seitz
|
|
|
|
|
<html>
<head>
<META http-equiv="refresh" content="1;URL=http://www.myserver.com/mydownload.zip">
</head>
<body>
Hey! Looky looky looky! It's not blank!!!
</body>
</html>
|
|
|
|
|
well still get the same problem
it display a new page with message
"The page cannot be displayed"
let suppose a page A contains the download link i want to start download stating on the same page so that new page with message "The page cannot be displayed" doesnot appear.
thanx
|
|
|
|
|
I have the following script that you might want to use.
If you call the script on the postback of a page, it will not redirect to a blank page.
Sorry I don't have time right now to explain it. If you need further information just notify me.
public void ServeFile(bool download, string fileLocation, string originalFileName, string fileType, ref System.Web.UI.Page currentPage)
{
System.IO.Stream iStream;
long dataToRead;
int length;
byte[] buffer = new Byte[10000];
try
{
iStream = new System.IO.FileStream(fileLocation, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
dataToRead = iStream.Length;
currentPage.Response.Clear();
if (download)
{
currentPage.Response.AddHeader("Content-Disposition", String.Concat("attachment; filename=", originalFileName));
currentPage.Response.ContentType = "application/octet-stream";
}
else
{
currentPage.Response.AddHeader("Content-Disposition", String.Concat("filename=", originalFileName));
currentPage.Response.ContentType = fileType;
}
currentPage.Response.AddHeader("Content-Length", iStream.Length.ToString());
while (dataToRead > 0)
{
if (currentPage.Response.IsClientConnected)
{
length = iStream.Read(buffer, 0, 10000);
currentPage.Response.OutputStream.Write(buffer, 0, length);
currentPage.Response.Flush();
buffer = new Byte[10000];
dataToRead = dataToRead - length;
}
else
dataToRead = -1;
}
}
catch (Exception e)
{
throw new ApplicationException("An unexpected error occured while serving file " + originalFileName, e);
}
"Democracy is two wolves and a sheep voting on what to have for dinner" - Ross
Edbert
Sydney, Australia
|
|
|
|
|
Hi,
Using vbscript to develop forms and windows CE.
Using MID string function returns NULL value to the form? Hard-coding returns value - is something amiss?
thanks.
|
|
|
|
|
In VBScript Null values only come from the database.
Is the value Empty, Nothing, or a zero-length string?
Unless you show some of the code you are using, you won't get anything better than wild guesses.
---
b { font-weight: normal; }
|
|
|
|
|
There is a variable A which does get printed, but while trying to mid the variable A to retrieve a part of the variable, it doesn't return any value. The mid function returns nothing.
Thanks.
|
|
|
|
|
As Guffa pointed out, without seeing source code, all you're gonna get is wild stabs in the dark - mine would be to check the Start and length params - you've probably cocked em up by a few psoitions
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
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
|
|
|
|
|