views:

99

answers:

3

Hi,

How can I call to a ASP.NET file (.aspx) from a VBS file that are both on the SAME server ?

I need that the VBS file will execute the asp.net file with some parameters.

Thanks

A: 

something like this?

Dim ie
Set ie = CreateObject("internetexplorer.app  location")
ie.Navigate "http://www.mysite.com/mypage.aspx?q=1"
ie.Visible=True

or

Set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "iexplore http://www.mysite.com/mypage.aspx?q=1", 9 
WScript.Sleep 10000 ' Give ie some time to load

'Close the browser 
WshShell.SendKeys "%F" 
WshShell.SendKeys "C"

or

rebember that you run web pages directly from the Task Scheduler and use curl

balexandre
Is there a way to do it without starting the explorer? remember that both files (vbs and aspx) are on the same machine.Thanks.
Assaf
using curl then ... you do everything just change .Run "curl" and options...
balexandre
A: 

You can use ServerXMLHttp:-

 dim xhr : set xhr = CreateObject("MSXML2.ServerXMLHttp.3.0")
 xhr.open "GET", "http://yoursite/youcode.ashx?params=x", false
 xhr.send
 if xht.status = 200 then
    msgbox "Success :)"
 else
    msgbox "Failed :("
AnthonyWJones
A: 

You can use the following in your .vbs file

Set winHttpRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
winHttpRequest.Open "GET", "http://localhost/mypage.aspx", false

winHttpRequest.Send

WScript.Echo(winHttpRequest.GetAllResponseHeaders())
WScript.Echo(winHttpRequest.ResponseText)

For more examples, see http://www.neilstuff.com/winhttp/

You should be able to call any URL (including .aspx pages) on your server (or on the internet)

Riaz Hosein