Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic ASP error with XMLHTTP request

I'm running Classic ASP along with ASP.net 4.0 on IIS 7.5.

In my classic ASP code is this code:

' Process @ alerts
Dim objHttp
set objHttp = Server.CreateObject("Microsoft.XMLHTTP")

objHttp.open "POST", strSiteRoot & "handlers/forumalerts.ashx?", false
objHttp.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
objHttp.Send "topicID=" & lngTopicID & "&threadID=" & lngLastPostID

set objHttp = nothing

This is sending a request to an ASP.net ASHX handler. When it is run, it hangs for a long time before finally sending the error message:

msxml3.dll error '800c0008'

The download of the specified resource has failed.

/forum/new_post.asp, line 1036

I've checked the URL it's posting to and it exists and is functioning. The data being sent is also correct.

Before I fresh installed Windows 7 it was working fine. Since reinstalling it fresh, and setting up IIS again this bit of code fails, leading me to beleive it is a permissions/identity error.

Can anyone tell me what could be causing this? I have 3 app pools:

ASP.net v4.0 (Integrated) (ApplicationPoolIdentity)
ASP.net v4.0 Classic (Classic) (ApplicationPoolIdentity)
DefaultAppPool (Integrated) (NetworkService)

Thanks for any help!

Edit: I found this error in the logs:

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 02/11/2011 14:55:42 
Event time (UTC): 02/11/2011 14:55:42 
Event ID: 4e550d910b934d2781707701f833e18e 
Event sequence: 39 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT-2-129647191892089824 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\inetpub\wwwroot\ScirraNew\ 
    Machine name: TOM-PC 

Process information: 
    Process ID: 7980 
    Process name: w3wp.exe 
    Account name: NT AUTHORITY\NETWORK SERVICE 

Exception information: 
    Exception type: ArgumentNullException 
    Exception message: Value cannot be null.
Parameter name: String
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Int32.Parse(String s)
   at forumalerts.ProcessRequest(HttpContext context) in c:\inetpub\wwwroot\ScirraNew\Handlers\forumalerts.ashx:line 13
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)



Request information: 
    Request URL: http://127.0.0.1/handlers/forumalerts.ashx 
    Request path: /handlers/forumalerts.ashx 
    User host address: 127.0.0.1 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: NT AUTHORITY\NETWORK SERVICE 

Thread information: 
    Thread ID: 39 
    Thread account name: NT AUTHORITY\NETWORK SERVICE 
    Is impersonating: True 
    Stack trace:    at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Int32.Parse(String s)
   at forumalerts.ProcessRequest(HttpContext context) in c:\inetpub\wwwroot\ScirraNew\Handlers\forumalerts.ashx:line 13
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)


Custom event details: 

Line 13 is the first request.form:

int TopicID = int.Parse(context.Request.Form["topicID"]);
like image 926
Tom Gullen Avatar asked Oct 30 '11 20:10

Tom Gullen


2 Answers

First step is to stop using Microsoft.XMLHTTP, you should not be using that in a service base scenario. Instead use MSXML2.ServerXMLHTTP.3.0 which is designed for use in services.

Also if the .ashx being posted inturn calls back in to originating ASP application then the thread starvation issue that Gaby aludes to may be occuring. Usually you can get away with this on a site that has light usage. However if you have ASP debugging enabled on the application then calling back into the ASP application will definitely hang. Note this does not apply in the simple ASP to ASHX scenario.

If your problem persists (which it probably will) then:-

  • install a copy of fiddler on your machine.
  • Fire up Fiddler
  • In a Command Prompt enter >netsh
  • The issue the command >winhttp set proxy 127.0.0.1:8888
  • Attempt to use your ASP page, you should see the POST captured by fiddler
  • Restore the winhttp proxy settings with >winhttp reset proxy

Now examine the Request/Response to of the POST in fiddler, this may reveal some clues as to where the real problem lies.

like image 118
AnthonyWJones Avatar answered Nov 15 '22 06:11

AnthonyWJones


If I understand correctly you are making a request to the same server as the calling one..

Read http://support.microsoft.com/kb/316451

Using ServerXMLHTTP or WinHTTP objects to make recursive Hypertext Transfer Protocol (HTTP) requests to the same Internet Information Server (IIS) server is not recommended. More specifically, the calling Active Server Page (ASP) should not send requests to an ASP in the same virtual directory or to another virtual directory in the same pool or process. This can result in poor performance due to thread starvation.

like image 45
Gabriele Petrioli Avatar answered Nov 15 '22 08:11

Gabriele Petrioli