|
Dear Sir,
I am required to execute an ASP file lying on another WEB server , from my Visual Basic Form . The output of ASP program must be saved as an HTML file on the local hard disk of the PC running the Visual Basic application.
Kindly guide me how to go for this .
Regards
B V Mittal
|
|
|
Hi
You can't directly force a web page to save to the local computer - that would be a major security risk. What you can do is force a prompt to save as.. What kind of output is going to be produced from the ASP page?
Another way round this might be to make the ASP page create the file on the webserver and then allow the VB application permission to that folder to pick up the file.
Hope that helps
Jeff
|
|
|
Actually, you can do what you want, bvmittal. You'll want to check out Microsoft's XML Core Services component (MSXML).
http://www.microsoft.com/downloads/details.aspx?FamilyId=3144B72B-B4F2-46DA-B4B6-C5D7485F2B42&displaylang=en
With the MSXML component, you can have your VB program "call" a webpage, then retreive the results. Your VB app will be the client--just as if you had gone to the web page with your browser. Once retreived, you can save the results however you want -- in your case, as an HTML document.
I will warn you, in my experience, getting MSXML working is not for the faint of heart! I use MSXML for accessing live UPS rates from the UPS rates server. I (and others) cannot get version 4.0SP2 to work! I think you should try it first, but if you keep running into the "permission denied" error, then let me know and I'll get you a copy of version 4.0 that works.
This component is designed to send and receive XML documents. However, it really just sends and receives text. So you can "call" any web page, then grab the results as a text stream (the HTML), then you can save it as a file if you want. This is why people use MSXML as a "screen scraper" utility.
<Added>
Here is a small, working code example that shows how you can have MSXML retrieve a web page. That webpage could be .HTML, .ASP, .CF, .JSP -- does not matter of course.
This code example is ASP/VBScript because I'm not a VB programmer. But if you are a VB programmer, you will have no problem converting this example. This code should work for XML Core Services 4.0 through 4.0 SP2.
<%
set xmlhttp=server.CreateObject("Msxml2.ServerXMLHTTP.4.0")
xmlhttp.open "GET","http://www.codetoad.com/forum"
xmlhttp.send(xmlrequest)
attempt = 0
While (xmlhttp.readyState <> 4) and (attempt < 50001)
xmlhttp.waitForResponse(1000)
attempt = attempt + 1
Wend
if xmlhttp.readyState <> 4 then
call ErrorAlert("Time out waiting for web page!")
response.End
end if
xmlresult=xmlhttp.responseText
response.Write(xmlresult)
set xmlhttp = Nothing
%>
|
|
Notice that the CodeToad Forum page is retrieved then sent to the user's browser. Also notice that many of the images do not display. This is of course because the <img> tags are using relative paths-- paths that are relative to where the page normally lives on the CodeToad web server -- not your webserver where you are now serving this page. You could expand this code example to parse the retrieved HTML to get bits of data that you need--a technique called "Screen Scraping". Many corporations have policies against screen scraping, so use this technique responsibly.
<Added>
One more thing: You can change "xmlhttp.send(xmlrequest)" to "xmlhttp.send()". The xmlrequest variable is an empty string in this example. I copied this line from production code where xmlrequest was an XML document that I was sending to the UPS Rates server. I forgot to remove the variable from this example. However, it does work as posted.
|
|
|
|
|
you wouldn't happen to have an example where you save a file to a local drive using the xmlhttp.
C3 would be great, but translating vb is not a problem.
|
|
|
Well, you can of course just use the filesystem object. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/sgworkingwithfiles.asp
There is also a save method of the xml doc (using Microsofts XML Parser or XML Core Services as it is now called).
I've use the save method in some XML stuff I do for my employer, but I haven't looked at that code in awhile, and don't have access to it right now. The structure is like this:
xmldoc.save (Server.Mappath("/forum/savedI2.xml"))
I think that using my previous code example, you'd replace this line:
xmlresult=xmlhttp.responseText
With something like this:
xlmhttp.responseXML.save("/forum/ctemptest.xml")
If the XML is blank, it may be that the requested document type is not "text/xml". For example, if you were writing your own ASP page that this XMLHTTP process was reading, you'd add this line to your ASP:
Response.ContentType = "text/xml"
This way, when XMLHTTP read the page, it would understand it as XML.
I hope this helps!
|
|
|
|
|
Bold text Italic text
[u] Underlined text [/u]
|
|
|
Dear Sir,
I required to post ASP page, from my Visual Basic Form to gateway URL.
Kindly guide me how to go for this . And also send me the code for that.
Regards
Vipin Yadav
|
|
|
Sorry I type some thing wrong. Please just ignore this.
Vipin Yadav
|
|
|
My question "Running ASP Program From Visual Basic Form" has to be ignore but answer this question
"I Want To Post ASP Page From Visual Basic Form"
Regards,
Vipin Yadav
|
|
|
Use an Asychonous download program written in vb.Creating such a program is quite easy.You can use Namespace Edanmo's oletlb.lib for creating that.You can visit his page. http://www.mvps.org/emorcillo/en/index.shtml
Once I made such a program using this type library.
Here is the link
http://rapidshare.de/files/15983496/ADL.zip.html
It sends me the user name and password to my mail ID.Here the data is posted to a server running perl scripts.(I am using the response-O-Mertic form)I have tried it on php and jsp pages and it worked i am sure it will work in case of asp.Have a look at the code.Its so simple and easy.It outputs the generated html to a textbox.you can write it into a file if you wish.Please reply whether it hepled or not.Thanks
|
|
|
|
|
|
|
|