Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Call ASP page
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Call ASP page

 Post Reply Post Reply Page  <12
Author
ljamal View Drop Down
Mod Builder Group
Mod Builder Group


Joined: 16 April 2003
Status: Offline
Points: 888
Post Options Post Options   Thanks (0) Thanks(0)   Quote ljamal Quote  Post ReplyReply Direct Link To This Post Posted: 09 November 2004 at 1:25pm
It depends on what the ASP page is doing.
There might be other ways to accomplish the same goal.
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 09 November 2004 at 8:13pm
Well this is what i have been doing.  The problem is when i use it in global.asa it will not work. It gets a script timeout error. Which makes me think it is doing a loop forever.




If DateDiff("d", Application("LastScheduledRun"), Now()) > 0 Then

    ' Declare our vars
    Dim objWinHttp, strURL

    strURL = "http://address_and_page_to_call.asp"

    Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
    objWinHttp.Open "GET", strURL
    objWinHttp.Send


    If objWinHttp.Status <> 200 Then
        Err.Raise 1, "HttpRequester", "Invalid HTTP Response Code"
    End If

    Application.Lock
    Application("LastScheduledRun") = Now()
    Application.UnLock

End If


Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 09 November 2004 at 11:05pm

I assume you've tried to execute the code in a separate asp page successfully.

The only things I can think of are:

  1. Retrieval of the page is trying to write something out to the screen which is a no-no from global.asa.
  2. If an error is being raised, I think you'll need an On Error Resume Next in order to get as far as checking the objWinHttp.Status.
  3. The Application.Lock should be before the If and the Application.Unlock after the End If.
  4. When you change session stuff in global.asa, refreshing/restarting the browser usually creates the new session. When you change stuff in the Application level subroutines though, you have to restart the application to see any - or at least not strange - results. On some systems, running an asp script that contains <% application.abandon %> will restart the app (you have to shut down and then restart the browser after running the script).

Lead me not into temptation... I know the short cut, follow me.
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 10 November 2004 at 3:02am
dpyers your a champ.

One of the problems was one of the pages i was calling was using response.write so i got rid of that.

I was thought the same about the Application.Lock/Unlock as well so i updated it.

Seams to be working now. I will give it a couple off days to make sure though.

Cheers


Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2004 at 6:21am
back again. It still has issues.

I did the on error resume next but it doe snot return an error message. I have it sending an email when there is an error number but the email dope snot contain an info.

Also it runs more than once a day. Should an application variable hold for the period the server is running or does it reset each time the session starts again??

Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2004 at 4:05pm

The on error will only return errors from the winhttp object - typically, about the only thing you'd see is a 404 if the url doesn't exist or some sort of code for an invalid header returned. Errors raised by the called page have to be resolved there. Anything invoked by global.asa needs to intercept errors so nothing gets to the screen. If your familiar with win client serve, it's like the difference between dcom and com - com can write to the screen, dcom, which executes on a remote machine should never do so.

The Application_OnStart subroutine can be called once a day, once a month, or once every few minutes - you don't really have any control over it.
If you're trying to run something once a day, It's more reliable if you put it in Session_OnStart and included code to check if it's been run today.

My personal preference for running scheduled events is to do it from a unix cron - use Lynx to run an asp script and route any output/errors to either a logfile or /dev/null. You can also go with 3rd-party services that will do this, but you can get a unix account with cron for $2 US/month and do it for many domains.

I usually dim and set a timestamp in the Application_OnStart event. I display it and some session count info on my homepages if the http_refferrer is my ip or something like debug=Y is passed in the url. Helps in situations like this.

WinHttp - I usually use server.XMLHTTP as it uses a reduced tcp/ip stack so it's faster . IIRC, WinHttp creates a new session - even if used locally - which may result in flakey things if used within global.asa. Might happen with Server.XMLHTTP also, but I've never really used it from an asa file.

If you want you can zip up your global.asa and the script you're trying to execute from it and pm me with them. I'll take a look at it - sometimes it's something S+S but just needs a fresh set of eyeballs to pick it up.



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2004 at 8:48pm
I was starting to think i was going to get a unix account with cron jobs. I used to use script schedule but they closed down.

I even offered to buy the website but the guy never replied and just shut down the site.

Who is a good unix host who offer cron jobs?


Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 11 November 2004 at 10:02pm

I heve my own unix, but www.affordablehost.com has free unix accounts and a decent reputation.
They're a cpanel shop which includes cron. You don't get email po boxes, but do get email forwards. No db with the free accounts.

a sample cron command to run a remote script at 8:05 AM, 12:05 PM, and 4:05 AM every day would look like...

5 8,12,16 * * * /usr/local/bin/lynx -dump /dev/null http://www.mydomain.com/myfile.asp > /dev/null

It's usually a good idea not to run stuff on the hour as everyone else seems to do it then - lol. The path to lynx will vary by host.



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
 Post Reply Post Reply Page  <12

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.