Can someone give me an example of how I can execute a program on a
corporate server and then download the response to the user? I'm not
sure if I'm asking this right.
Here is the asp code used today. I am attempting to recreate in
ASP.NET.
Thanks in advance,
Clem
--------------------------------------------------------------------------------------------------------------------------------------
Set HttpObj = Server.CreateOb ject("WinHTTP.W inHTTPRequest.5 .1")
HttpObj.setTime outs 5000, 5000, 15000, 15000
HttpObj.open "GET", "http://" & serverpath & "/doc_qanda.exe?" &
Escape(doc_num) & ",1", False
HttpObj.send
html = HttpObj.respons eText
pos = Instr(html, "window.locatio n=""") + 17
If Not Response.IsClie ntConnected Then
Set HttpObj = Nothing
Response.End
End If
If pos > 17 Then
HttpObj.setTime outs 5000, 5000, 15000, 15000
HttpObj.open "GET", Mid(html, pos, Instr(pos, html, """") - pos),
False
HttpObj.send
End If
BinaryData = HttpObj.respons eBody
ContentType = HttpObj.getResp onseHeader("Con tent-Type")
Set HttpObj = Nothing
If Not Response.IsClie ntConnected Then
Response.End
End If
Response.AddHea der "Content-Type", ContentType
Response.AddHea der "Content-Length", LenB(BinaryData )
Response.AddHea der "Content-Disposition", "attachment ; filename=" &
Escape(handle)
Response.Binary Write BinaryData
Response.Flush
%>
-------------------------------------------------------------------------------------------------------------------------------------- 8 5256
Here you go: http://msdn.microsoft.com/library/de...ponsetopic.asp
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
<jd*******@park er.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.com... Can someone give me an example of how I can execute a program on a corporate server and then download the response to the user? I'm not sure if I'm asking this right. Here is the asp code used today. I am attempting to recreate in ASP.NET.
Thanks in advance, Clem -------------------------------------------------------------------------------------------------------------------------------------- Set HttpObj = Server.CreateOb ject("WinHTTP.W inHTTPRequest.5 .1") HttpObj.setTime outs 5000, 5000, 15000, 15000 HttpObj.open "GET", "http://" & serverpath & "/doc_qanda.exe?" & Escape(doc_num) & ",1", False HttpObj.send html = HttpObj.respons eText pos = Instr(html, "window.locatio n=""") + 17
If Not Response.IsClie ntConnected Then Set HttpObj = Nothing Response.End End If
If pos > 17 Then HttpObj.setTime outs 5000, 5000, 15000, 15000 HttpObj.open "GET", Mid(html, pos, Instr(pos, html, """") - pos), False HttpObj.send End If
BinaryData = HttpObj.respons eBody ContentType = HttpObj.getResp onseHeader("Con tent-Type") Set HttpObj = Nothing If Not Response.IsClie ntConnected Then Response.End End If
Response.AddHea der "Content-Type", ContentType Response.AddHea der "Content-Length", LenB(BinaryData ) Response.AddHea der "Content-Disposition", "attachment ; filename=" & Escape(handle) Response.Binary Write BinaryData Response.Flush %> --------------------------------------------------------------------------------------------------------------------------------------
Thank you for the quick response. I assume I should put my execution
statement ("http://" & serverpath & "/doc_qanda.exe?" ) in place of
"Invalid Site"? I'm not sure what they mean by invalid site? Why
would someone code an invalid site purposely?
Also, can I specify a "GET" vs. "POST"?
Thank you again!
Come on, now. This was documentation on the WebException.Re sponse property
of the WebException class. The code in it was an example of how to use the
WebException.Re sponse property. It had legitimate code for getting a
Response from an HttpWebRequest, but using an invalid URL, in order to get
the WebException. The introductory text before the example read:
Remarks
Some Internet protocols, such as HTTP, return otherwise valid responses
indicating that an error has occurred at the protocol level. When the
response to an Internet request indicates an error, WebRequest.GetR esponse
sets the Status property to WebExceptionSta tus.ProtocolErr or and provides
the WebResponse containing the error message in the Response property of the
WebException that was thrown. The application can examine the WebResponse to
determine the actual error.
Example
[Visual Basic, C#, C++] The following example checks the Status property and
prints to the console the StatusCode and StatusDescripti on of the underlying
HttpWebResponse instance.
You were supposed to read the code, read the documentation, derive the
correct code for getting a Response from an HttpWebRequest, note the
location in the .Net Framework class library documentation for future use,
and adapt the code to your needs.
For future use, the documentation for the entire CLR class library is in
that reference, and it should be very useful to you when this sort of
situation arises.
The full documentation for the HttpWebRequest class can be found at: http://msdn.microsoft.com/library/de...classtopic.asp
The full documentation for the HttpWebResponse class can be found at: http://msdn.microsoft.com/library/de...classtopic.asp
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:uq******** ******@TK2MSFTN GP12.phx.gbl... Here you go:
http://msdn.microsoft.com/library/de...ponsetopic.asp
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer Who is Mighty Abbott? A twin turret scalawag.
<jd*******@park er.com> wrote in message news:11******** *************@g 47g2000cwa.goog legroups.com... Can someone give me an example of how I can execute a program on a corporate server and then download the response to the user? I'm not sure if I'm asking this right. Here is the asp code used today. I am attempting to recreate in ASP.NET.
Thanks in advance, Clem -------------------------------------------------------------------------------------------------------------------------------------- Set HttpObj = Server.CreateOb ject("WinHTTP.W inHTTPRequest.5 .1") HttpObj.setTime outs 5000, 5000, 15000, 15000 HttpObj.open "GET", "http://" & serverpath & "/doc_qanda.exe?" & Escape(doc_num) & ",1", False HttpObj.send html = HttpObj.respons eText pos = Instr(html, "window.locatio n=""") + 17
If Not Response.IsClie ntConnected Then Set HttpObj = Nothing Response.End End If
If pos > 17 Then HttpObj.setTime outs 5000, 5000, 15000, 15000 HttpObj.open "GET", Mid(html, pos, Instr(pos, html, """") - pos), False HttpObj.send End If
BinaryData = HttpObj.respons eBody ContentType = HttpObj.getResp onseHeader("Con tent-Type") Set HttpObj = Nothing If Not Response.IsClie ntConnected Then Response.End End If
Response.AddHea der "Content-Type", ContentType Response.AddHea der "Content-Length", LenB(BinaryData ) Response.AddHea der "Content-Disposition", "attachment ; filename=" & Escape(handle) Response.Binary Write BinaryData Response.Flush %> --------------------------------------------------------------------------------------------------------------------------------------
Here is a more direct example:
(puts the contents of a remote document onto the page)
System.Net.Http WebRequest req =
(System.Net.Htt pWebRequest)Sys tem.Net.WebRequ est.Create(url) ;
System.Net.Http WebResponse resp = (System.Net.Htt pWebResponse)
req.GetResponse ();
System.IO.Strea mReader rd = new
System.IO.Strea mReader(resp.Ge tResponseStream ());
Response.Write( rd.ReadToEnd()) ;
rd.Close();
resp.Close();
where 'url' is a String variable with the URL of the document you want
to retrieve.
Sorry to bother you Kevin. If I'm not an experienced .NET user, I
shouldn't be using .NET. Thanks anyway.
This is very helpful. Thank you,
When I use this url from my desktop shortcut, I get the document back
just fine. When using it from my aspx page on localhost, I get a blank
document.
No exception is thrown so I know it's not an authorization issue.
URL = "http://cyl01002/cyl/doc_qanda.exe?1 33154"
Try
Dim myHttpWebReq As HttpWebRequest = CType(WebReques t.Create(URL),
HttpWebRequest)
Dim myHttpWebResp As HttpWebResponse =
CType(myHttpWeb Req.GetResponse (), HttpWebResponse )
Dim sr As StreamReader = New
StreamReader(my HttpWebResp.Get ResponseStream)
Response.Write( sr.ReadToEnd)
sr.Close()
myHttpWebResp.C lose()
Catch e as WebException
Response.Write( "<BR>Error Retrieving document contents " & e.Message)
End Try
Any Ideas?
I apologize for my newbie question.
Thanks in advance
Found my solution.
Because the URL was an EXE that was ultimately returning the document,
I had to use a MemoryStream instead of a StreamReader. (content type
was not known)
This worked...
Dim ms As New MemoryStream
Dim br As BinaryReader = New
BinaryReader(my HttpWebResp.Get ResponseStream)
Dim buffer As Byte()
buffer = br.ReadBytes(40 96)
While buffer.Length > 0
ms.Write(buffer , 0, buffer.Length)
buffer = br.ReadBytes(40 96)
End While
Response.Binary Write(ms.ToArra y)
Double bonus, it runs faster. Thanks again, This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: HikksNotAtHome |
last post by:
In Mozilla 1.4b, when the URL is set to a local URL, it works as expected.
function showIt(){
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "blank.html" ,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
document.myForm.outputSource.value = xmlhttp.responseText;
}
}
|
by: Bp |
last post by:
I'm writing a simple HTTPRequest that retrieves the content of a web page.
Dim httpReq As System.Net.HttpWebRequest
Dim httpResp As System.Net.HttpWebResponse
httpReq = CType(System.Net.WebRequest.Create(URLString),
System.Net.HttpWebRequest)
httpResp = CType(httpReq.GetResponse(), System.Net.HttpWebResponse)
The problem is that on certain pages, I get a WebException of "The remote
|
by: bobsawyer |
last post by:
I've been building a series of SELECT lists that are populated
dynamically using HTTPRequest. Things are going pretty well, and I've
got the whole thing working flawlessly in Mozilla/Firebird.
Unfortunately, Internet Explorer doesn't quite work as expected -- it
gives me an "invalid argument" error that I don't know how to fix.
Here's the entire script, with form, annotated to explain what I'm
doing and where the problem is occurring. I...
|
by: Daniel Rimmelzwaan |
last post by:
I am having trouble getting the XML out of an HttpRequest object.
I am sending the XML from biztalk into my aspx page, after which I want to
take the XML out of it and process it using a MSXML.DOMDocument. I
understand that in the Request object, it is stored as a binary, and I can't
figure out how to translate it into a text string.
Do I need to read it into a byte variable and then move it to the
DOMDocument, or is there a method I...
|
by: selen |
last post by:
if any one have any sample or document which can help me to parse word
document to store in sql server database c# aspnet
Thanks
| |
by: Eþref DURNA |
last post by:
My Aim is to make a windows application download which support session and
cookies.
There is a web site which gives images as links like this
http://www.comstock1700k.com/download/22570094.jpg?h=3b456ad7eceff24e9ad547e1dfa96098&t=1132241687&u=esref
When ever I click to save as a target as or download using flash get that
programs could download the file correctly
but when ever I use
WebClient or httprequest it sends me to the login...
|
by: Gunnar |
last post by:
I am finding some unusual behavior with techniques I am using to
show/hide/update data without having to refresh the page. I'm quite
sure it's developer ignorance on my part and would be grateful for any
suggestions.
My page has 10 tables with their visibility controlled by the user
making a menu selection. For example, selecting menu_1 calls a
function which displays table_1 by setting table_1's style display:
block and hides tables...
|
by: Doug van Vianen |
last post by:
Hi,
Is there some way in JavaScript to stop the downloading of pictures from a
web page?
Thank you.
Doug van Vianen
|
by: marcofabian |
last post by:
Hi: I've ben looking for a long time for an answer to mi problem. The thing is that I'm uin httprequest object to load files inside div tags. It works ok. My problem is that any javascript code defined inside my loaded fields simply can't bedetected, can0t be executed. I really need this to work because the I work with javascript code to measure he visits to this loaded files. And this code is defined on every page that is called by the...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |