Good morning experts!
I'm trying to figure out a way to download a report from one of my companies intranet sites, and I've hit a bit of a snag.
The report differs by two items: the session id (auto-generated on log on), and the report key (which I get from another system). I've used screen scraping to get the session ID at log on, and I provide the key.
However, when I try to use My.Computer.Network.DownloadFile, the file that downloads is a page (within the system) that says the session has expired. I have a feeling it's because there's a web-based application that generates the report. -
path = _
-
"http://system.internal.com/xcgi/xnet.exe?sys=sys" & _
-
"&ses=" & session & _
-
"&ISN=&TRN=&cmd=DWN&rid=" & _
-
"&rpt=/EDICLAIM/HOSPMED%2ECCMEDC%2E%4002" & _
-
"&ver=1722" & _
-
"&ixn=" & s & "&ixv=" & key
-
-
Try
-
Dim file As String = _
-
My.Computer.FileSystem.SpecialDirectories.Desktop _
-
& "\test.xls"
-
If My.Computer.FileSystem.FileExists(file) Then Kill(file)
-
My.Computer.Network.DownloadFile(path, file)
-
Process.Start(file)
-
Catch ex As Exception
-
MsgBox(ex.Message)
-
End Try
-
Now, if I copy the string into the browser, it opens a file download dialog and I can save it as normal. However, trying to use VB to do the same results in an error. Does anyone have any suggestions as to how to overcome this?
Thank you!
5 1636
You should be using HttpWebRequest to download the file should you not?
It's funny you should say that! I continued trying to figure this out, and just tested using that: -
Dim request As HttpWebRequest = WebRequest.Create(path)
-
Dim response As HttpWebResponse = request.GetResponse()
-
Dim reader As New StreamReader(response.GetResponseStream())
-
Dim f As New IO.StreamWriter(file)
-
-
f.Write(reader.ReadToEnd())
-
f.Close()
-
reader.Close()
-
-
Process.Start(file)
-
The file that opens after this runs is still the error page. Is there something I'm missing?
You may need to do the entire process for grabbing the session id and etc with HttpWebRequest objects?
If you paste the path you provided into a new IE (or FF) window, does it give the correct response? (I say new window, but I mean new instance, re-using an old instance might send down hidden headers obtained from a previous successfull request to the website)
I tried copying the address into another window and it gave the error page.
Looking at the JavaScript behind the web page's download button, it looks simple enough: -
function goToDownload() {
-
if (GetCookie("actind") == "") {
-
window.location = "/xcgi/xnet.exe?sys=JHSE2&ses=0ECCE09B851B522572AFFB6451E39C6F55EAFFDC&ISN=&TRN=&cmd=DWN&rid=&rpt=/CLM/HOSPMED%2ECCMEDC%2E%4002&ver=1722&ixn=CKEY$&ixv=2008011840100401017442";
-
}
-
}
-
The string generate by the program: -
xcgi/xnet.exe?sys=JHSE2&ses=0ecce09b851b522572affb6451e39c6f55eaffdc&ISN=&TRN=&cmd=DWN&rid=&rpt=/CLM/HOSPMED%2ECCMEDC%2E%4002&ver=1722&ixn=CKEY$&ixv=2008011840100401017442
-
Now, I know nothing about cookies, so I'm not sure that it's referencing. Plus, reading through the cookie itself, I couldn't find anything with a label of "actind", so I'm a little confused.
Is there a way to trick the WebRequest into thinking it's coming from the same instance?
I had a breakthrough! -
Dim d As System.Windows.Forms.HtmlDocument = Me.WebBrowser1.Document
-
d.InvokeScript("goToDownload")
-
That brings up the dialog box for saving something from the internet to your computer. Now, short of simulating keystrokes, is there a way to NOT have the save file dialog box appear?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: James Kirk |
last post by:
The script below allows me to link to a file and as the user clicks to
download, the 'File Download' windows appears as normal, and the user can
download...
The original page is then redirected...
|
by: lawrence |
last post by:
Under the domain publicpen.com I've several dozen sites in
subdiretories, such as www.publicpen.com/honenbeger. I've no trouble
with any of these sites. But under one, which I put in yesterday,...
|
by: D. Alvarado |
last post by:
Hello, I would like to design a page that measures the user's download
connection. Does anyone have an example link or script that might aid
me in this task?
Thanks, - Dave
|
by: gb |
last post by:
hi,
i placed System.Windows.Forms.WebBrowser in my
WinForm. When i tried loading word document, it opens
the File Download window. My question is how can i avoid
the File Download window from...
|
by: zbcong |
last post by:
hello
i find following link:
http://www.microsoft.com/seminar/events/webcasts/library/default.mspx
that could link to archieved online webcast,but i can't find how to download
them.who can tell...
|
by: Brian Paul |
last post by:
When a user clicks on a linkbutton on a page, i would like to render a printer-friendly version of the asp.net page and download it as an html attachment to the browser. The code below works great,...
|
by: ACaunter |
last post by:
Hi there,
when one of my pages loads up, the download dialog box pops up to download a
file.. but the window turns all white and even after you download the file,
the window stays white..
what...
|
by: harold.saldanha |
last post by:
My objective is to redirect to another web page after download is
complete.
I have an activeX called to download a few dlls using the following
code
document.writeln(' <OBJECT ID="MQC" ');...
|
by: torbjorn.maro |
last post by:
I'm the developer of an enterprise level web application that among
other things handles documents. The documents are stored in a
database. There is now simple functionality to check out and...
|
by: Ciary |
last post by:
hey all,
i have another problem. basically the question is: how do i make sure a file is downloaded instead of opened?
but i'll explain the situation. i'm trying to download a file using a...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |