How can I discover why a Classic ASP page isn't responding to an HttpWebRequest?

1

Prefix: Unfortunately, rewriting these Classic ASP pages into ASP.NET is not an option. This is a complex legacy application that we're maintaining.

I'm having trouble getting an HttpWebRequest to POST to a Classic ASP page within the same web application. The page works quickly and correctly in a browser.

Expected result:

The HttpWebRequest should POST to the page and get the HTML result.

Actual result:

The HttpWebRequest waits for the default 100-second timeout and then fails.

Error message:

System.Net.WebException
  HResult=0x80131509
  Message=The operation has timed out

Things I've tried:

  • Added a CookieContainer, as suggested here
  • Wrapped the HttpWebResponse in a Using block, as suggested here
  • Attempted to inspect the HTTP traffic using Telerik Fiddler (no traffic was recorded for the request)
  • In order to rule out the ASP page itself as the culprit, reduced its content to a bare minimum:

    <!DOCTYPE html>
    <html>
      <head>
        <meta charset="utf-8" />
        <title>Page</title>
      </head>
      <body>
        <p>This is the page.</p>
      </body>
    </html>
    

Here's the code: (It fails on line 32, GetResponse())

---------------------------------------------------
 Generic Handler: SignIn.ashx
---------------------------------------------------

 1    Imports System.Net
 2
 3    Public Class Labels
 4       Implements IHttpHandler
 5
 6       Sub ProcessRequest(Context As HttpContext) Implements IHttpHandler.ProcessRequest
 7         Dim oFormData As NameValueCollection
 8         Dim oResponse As HttpWebResponse
 9         Dim sResponse As String
10         Dim aPostData As Byte()
11         Dim oRequest As HttpWebRequest
12         Dim sUrl As String
13
14         sUrl = "http://domain.local/signin.asp"
15
16         oFormData = HttpUtility.ParseQueryString(String.Empty)
17         oFormData.Add("username", "username")
18         oFormData.Add("password", "password")
19
20         aPostData = Encoding.ASCII.GetBytes(oFormData.ToString)
21
22         oRequest = WebRequest.Create(sUrl)
23         oRequest.AllowAutoRedirect = False
24         oRequest.ContentLength = aPostData.Length
25         oRequest.ContentType = "application/x-www-form-urlencoded"
26         oRequest.Method = WebRequestMethods.Http.Post
27
28         Using oStream = oRequest.GetRequestStream
29           oStream.Write(aPostData, 0, aPostData.Length)
30         End Using
31
32         oResponse = oRequest.GetResponse
33
34         Using oReader As New StreamReader(oResponse.GetResponseStream)
35           sResponse = oReader.ReadToEnd
36         End Using
37       End Sub
38
39       ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
40         Get
41           Return False
42         End Get
43       End Property
44    End Class

How can I debug this and determine what's going on? (Note that static HTML pages load just fine, as well as ASPX and ASHX files. This occurs only with Classic ASP pages.)

asp.net
post
asp-classic
timeout
httpwebrequest
asked on Stack Overflow Oct 13, 2019 by InteXX • edited Oct 17, 2019 by InteXX

2 Answers

0

This one was an oddball. But it went away after the next reboot.

answered on Stack Overflow Nov 6, 2019 by InteXX
0

If you're calling the same Session in the responding page, you're discovering that ASP is single-threaded and will hang if two separate threads are attempted.

Don't call the session in the responding page, and that may clear things up.

answered on Stack Overflow Nov 15, 2019 by Stephen R • edited Nov 15, 2019 by InteXX

User contributions licensed under CC BY-SA 3.0