ASP.NET & IIS 7.0 -- HTTPS Site Warmup Script - asp.net

I have an ASP.NET 4.0 site on IIS 7.0 that is having first time load issues described here.
I've done some testing, and can confirm that it's only the first load of the page that is slow; every subsequent page loads normally. After googling around for this, I found a "warmup" script that can send an HTTP request the first time after the app pool is recycled, and this seems to fix the problem. BUT, I'm not sure if it will work when I force set the page to use only HTTPS/SSL?
The script I'm currently using is as follows:
Dim website1
website1 = "http://<website domain>/Auth/Login.aspx"
Function WarmUpSite(strURL)
On Error Resume Next
Dim objHTTP
Set objHTTP = CreateObject("MSXML2.XMLHTTP")
objHTTP.Open "GET", strURL, False
objHTTP.Send
If Err.Number=0 And objHTTP.Status=200 Then
Hget=strURL & " has been warmed up successfully at: "&Date()&" "&Time()
Else
Hget=strURL & " found error at: "&Date()&" "&Time()
End If
Set objHTTP = Nothing
'Section for writing into a text file
Const FOR_APPENDING = 8
strFileName = "C:\WarmUpLog.txt"
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objTS = objFS.OpenTextFile(strFileName,FOR_APPENDING)
objTS.WriteLine Hget
End Function
WarmUpSite(website1)
So my question is how I would make this work if the website I'm warming up is a login page that will be an HTTPS address, not HTTP? My apologies if this is a dumb question, I do relatively little web work.

Well, apparently it just involved changing the value of website1 to an HTTPS url.
;)

Related

Classic ASP routine calling a page on same server

I'm moving an old ASP application from a Windows Server 2012R2 to a new Windows Server 2016 Standard Edition:
Old server had IIS 8, new server uses IIS 10
this application has some routines that makes an MSXML2.ServerXMLHTTP.6.0 call to a page hosted on the same server:
the problem is that this routine works on the old server, but does not work on the new server
I build this small routine to make the test
<%
Dim xmlhttp
Dim payload
payload="OID="&Timer*100
Set xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
xmlhttp.setTimeouts 30,500,1000,1000
xmlhttp.Open "GET", "http://sameserver.com/test.asp?"&payload , false
On Error Resume Next
xmlhttp.Send
If Err.Number Then
response.write "ERROR: Could Not Retrieve Remote Server <br> Error Number: "&Err.Number&"<br>Error Description: "&Err.Description
Err.Clear
Else
response.write = "OK: "&xmlhttp.ResponseText
End If
On Error Goto 0
Set xmlhttp = nothing
%>
that works on the old server but on the new server returns
Error Number: -2147012894
Error Description: Operation Timeout
I thought there were some bad/missing settings on new server, perhaps in IIS Settings, but I also tried a very simple test in PHP, that works fine:
<?php
$timer= new DateTime();
$payload='OID='.$timer->format('Y-m-d%20H:i:s');
$url='http://sameserver.com/test.asp?'.$payload;
echo file_get_contents($url);
?>
Clearly I can change these routine and use PHP, but I'm afraid that this error could create also other, at present, undisclosed issues
Can suggest the possible reason, or, at least, which checks has to be made?
Thanks
Your answer is here. Microsoft recommends not making ServerXMLHTTP to the same server. There are probably alternatives; it's hard to tell what you're trying to do from the code you posted.

msxml3.dll error '80072ee2' in ASP page - we are using a different Application Pool

There are lots of questions that ask about the 80072ee2 "The operation timed out" error in msxml3.dll, but most are resolved by moving the requested URL to a different application pool. But, we already do this and are still getting this error on a semi-regular basis.
We're running a Windows 2008 server and IIS7.5 - the website is Classic ASP and the code is:
set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.open "GET", "http://www.mysite.co.uk/_search/search.php", false
xmlhttp.send ""
strResponseText = xmlhttp.responseText
set xmlhttp = nothing
The folder '_search' is a virtual folder and is set to use a separate application pool from the main site. It is a busy-ish site, and we don't get a timeout every-time it's called... but once you get one, there are often a number of them in succession. We know this is happening because we're logging the 500 errors on the site.
Does anyone have any ideas (please don't suggest re-writing the Classic ASP or PHP - it's not possible at the moment)?
Thanks
Your code looks absolutely fine. Two things you can try though.
First try
Server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
This may not make any difference, but you're msxml6.dll - which is present on IIS7 - rather than the older msxml3.dll
Second, if you have Remote desktop access, see what happens when you try to access http://www.mysite.co.uk/_search/search.php from the server's own copy of IE. I've encountered situations where you can't see a site the server hosts itself through the external URL and you have to use localhost or 127.0.0.1
I solved it by creating a new site with the same physical path domain name etc but different port number (like 81)
xmlhttp.open "GET", "http://www.mysite.co.uk:81/_search/search.php", false

401 Unauthorised errors when attempting to download ASP page to file

Issue
Msxml2.ServerXMLHTTP keeps returning 401 - Unauthorised errors each time we attempt to read the contents of a file (ASP) from a web server.
Source server is running IIS6, using NTLM integrated login.
This process has been used successfully before, but only in as far as extracting XML files from external websites, not internal ones.
The proxy settings in the registry of the server on which the script is run has also been updated to bypass the website in question, but to no avail.
All paths identified in the VBScript have been checked and tested, and are correct.
User running the script has correct read/write permissions for all locations referenced in the script.
Solution needed
To identify the cause of the HTTP 401 Unauthorised messages, so that the script will work as intended.
Description
Our organisation operates an intranet, where the content is replicated to servers at each of our remote sites. This ensures these sites have continued fast access to important information, documentation and data, even in the event of losing connectivity.
We are in the middle of improving the listing and management of Forms (those pesky pieces of paper that have to be filled in for specific tasks). This involves establising a database of all our forms.
However, as the organisation hasn't been smart enough to invest in MSSQL Server instances at each site, replication of the database and accessing it from the local SQL server isn't an option.
To work around this, I have constructed a series of views (ASP pages) which display the required data. I then intend to use Msxml2.ServerXMLHTTP by VBScript, so I can read the resulting pages and save the output to a static file back on the server.
From there, the existing replication process can stream these files out to the site - with users having no idea that they're looking at a static page that just happened to be generated from database output.
Code
' Forms - Static Page Generator
' Implimented 2011-02-15 by Michael Harris
' Purpose: To download the contents of a page, and save that page to a static file.
' Target category: 1 (Contracts)
' Target Page:
' http://sharename.fpc.wa.gov.au/corporate/forms/generator/index.asp
' Target path: \\servername\sharename\corporate\forms\index.asp
' Resulting URL: http://sharename.fpc.wa.gov.au/corporate/forms/index.asp
' Remove read only
' Remove read only flag on file if present to allow editing
' If file has been set to read only by automated process, turn off read only
Const READ_ONLY = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.GetFile("\\server\sharename\corporate\forms\index.asp")
If objFile.Attributes AND READ_ONLY Then
objFile.Attributes = objFile.Attributes XOR READ_ONLY
End If
Dim webObj, strURL
Set webObj = CreateObject("Msxml2.ServerXMLHTTP")
strURL = "http://sharename.fpc.wa.gov.au/corporate/forms/generator/index.asp"
webObj.Open "GET", strURL
webObj.send
If webObj.Status=200 Then
Set objFso = CreateObject("Scripting.FileSystemObject")
Set txtFile = objFso.OpenTextFile("file:\\servername.fpc.wa.gov.au\sharename\corporate\forms\index.asp", 2, True)
txtFile.WriteLine webObj.responseText
txtFile.close
ElseIf webObj.Status >= 400 And webObj.Status <= 599 Then
MsgBox "Error Occurred : " & webObj.Status & " - " & webObj.statusText
Else
MsgBox webObj.ResponseText
End If
Replace your line:
webObj.Open "GET", strURL
With:
webObj.Open "GET", strURL, False, "username", "password"
In most cases 401 Unauthorized means you haven't supplied credentials. Also you should specifiy False to indicate you don't want async mode.
It sounds like the O.P. got this working with the correct proxy settings in the registry (http://support.microsoft.com/kb/291008 explains why proxy configuration will fix this). Newer versions of ServerXMLHTTP have a setProxy method that can be used to set the necessary proxy configuration in your code instead.
In the O.P. code above, after webObj is created, the following line of code would set up the proxy correctly:
webObj.setProxy 2, "0.0.0.0:80", "*.fpc.wa.gov.au"
ServerXMLHTTP will pass on the credentials of the user running the code if it is configured with a proxy, and if the target URL bypasses that proxy. Since you are bypassing the proxy anyway, you can make it a dummy value "0.0.0.0:80", and make sure your target url is covered by what you specify in the bypass list "*.fpc.wa.gov.au"
I would first test if you can reach your url through a normal browser on the same server X you run your code on (A). I would try then reach the url from another PC. One never used to reach that url but in the same network as server X (B).
If B works but A doesn't I would suspect that for some reason your source server (i.e. that one that serves the url) blocks server X for some reason. Check the security settings of II6 and of NTLM.
If both A and B don't work, there is something wrong more in general with your source server (i.e. it blocks everything or NTML doesn't allow you in).
If A works (B doesn't matter then), the problem has to be somewhere in your code. In that case, I would recommend fiddler. This tool can give you the HTTP requests of both your browser and your code in realtime. You can then compare both. That should give you at least a very strong hint about (if not immediately give you) the solution.

Cross domain XMLHttpRequest in classic ASP

My code is working fine till i migrate it to another server with firewall. After since, some part of my code is not working. Its seem to be the xmlhttp POST problem. Can someone point me to the right direction and how to determine if the firewall is the problem. My client insisted to me to use classic asp, so i cannot upgrade to .net.
Dim objHttp
SUBMIT_URL = "http://www.abc.com/confirm.asp"
Call Process()
Public Sub Process()
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")
'set the timeout values in milliseconds
lResolve = 1 * 1000
lConnect = 1 * 1000
lSend = 2 * 1000
lReceive = 2 * 1000
objHttp.open "POST", SUBMIT_URL, false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send str
if err.number <> 0 then
Response.Write "Error : " & err.Description
err.Clear
end if
End Sub
It's working almost fine for me. Seems that there's a redirection on the landing page you're calling that cannot be handled. Doesn't seems to be a firewall problem (maybe a proxy application like Charles or Fiddler can help you to see if there are communication problems due to your firewall, but I don't think so).
So try to point to the final destination page:
SUBMIT_URL = "http://abc.go.com/confirm.asp"
I don't really see the point on the timeouts variables unless you cut out come of the code before posting here.

schedule webpage

I need to schedule several different pages on several different sites to be run at certain times, usually once a night. Is there any software out there to do this? it would be nice if it called the page and then recorded the response and whether the called page was successful run or not. I was using Helm on a different box and it had a nice Web Scheduler module but Helm is not an option for this machine. This is a Window Server 2008 box.
We use standard scheduled tasks that call a bat file that calls a VBS file. I know it is not the most elegant solution ever, but it consistently works.
BAT:
webrun.vbs http://website.com/page.aspx
VBS:
dim URL, oArgs
Set oArgs = WScript.Arguments
if oArgs.Count = 0 then
msgbox("Error: Must supply URL")
wscript.quit 1
end if
URL = oArgs(0)
on error resume next
Set objXML = CreateObject("MSXML2.ServerXMLHTTP")
if err then
msgbox("Error: " & err.description)
wscript.quit 1
end if
' Call the remote machine the request
objXML.open "GET", URL, False
objXML.send()
' return the response
'msgbox objXML.responSetext
' clean up
Set objXML = Nothing
The code in the VBS file is almost assuredly both overkill and underwritten, but functional none-the-less.
How about wget.exe and the task scheduler?
The code given in the upper example has some issues with the task being active during the loading of the website. The website is loading 2 minutes but the task is already done in 1 second, which brings a problem when you execute it every 5 minutes. If the website loads 10 minutes and the task is already done in 1 second it wil execute again that while I want it to wait the loading time of the website.
So what I've done is the following (this script will keep the task busy as long the website is loading):
dim URL, oArgs, objXML
Set oArgs = WScript.Arguments
URL = oArgs(0)
on error resume next
Set objXML = CreateObject("Microsoft.XMLDOM")
objXML.async = "false"
objXML.load(URL)
Set objXML = Nothing
If it's not a requirement to schedule them from the same box, have a look to Zoho's site24x7.
It is initially designed to monitor web sites but it has an option to record expected answers and compare them so you can use it for your purpose with the added security of an external site. It's not free however except for few urls.
They are other similar providers but they looked pretty good last time I searched the web on this topic.
I ended up using this script and Task Scheduler, simple and works great:
Call LogEntry()
Sub LogEntry()
'Force the script to finish on an error.
On Error Resume Next
'Declare variables
Dim objRequest
Dim URLs
URLs = Wscript.Arguments(0)
Set objRequest = CreateObject("Microsoft.XMLHTTP")
'Open the HTTP request and pass the URL to the objRequest object
objRequest.open "POST", URLs, false
'Send the HTML Request
objRequest.Send
Set objRequest = Nothing
WScript.Quit
End Sub
Then I just call it with the URL I want run as an argument:
Similar (though possibly more powerful) is netcat and its windows port
fyi - wget is GNU standard license, so I'm not sure it's usable for most commercial/proprietary systems.
I use http://scheduler.codeeffects.com. Very effective and reliable, no complains.

Resources