First call to HttpWebRequest.GetResponse() takes forever and fails, after that it works?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I am working in C# .NET 1.1. My app has a button on its main form that
checks to see if it has access to a file on our server, just an XML
file. On our server we are running W2K IIS with a virtual directory,
set to Windows Authentication. I am creating an HTTPWebRequest object
on the client, and setting its Credentials to
CredentialCache.DefaultCredentials. Also, I have tried numerous
Timeout settings, but they have not made a difference.

When I run the app on a client that is connected to our internal
network, everything works great. When I try and run through a client
that is connected through the Internet, and come in through a secure
tunnel, it takes forever and then fails the first time, but if we try
again without closing the app, it works every time there after.

Now, first off I have noticed while tracing the port that the call to
GetResponse() first returns a 401 error, but then it authenticates and
goes through, the same from both clients. I have noticed in the forums
that people have mentioned that GetResponse() actually may get a 401
error first so that the client can then send authentication.

When I use IE to access the URL to this file from the client on the
Internet, it works the first time and is fast.

What I have had to do to remedy the situation for now is test the
return value I get from my first check, and if it fails, I repeat it.
It still has the time delay but it ends up connecting without making
the user click twice.

What is wrong with GetResponse()? What else can I try to change to
have it connect the first time?

Thanks in advance,
Scott

.



Relevant Pages

  • Re: Subscript out of range, obvious?
    ... All your client apps could declare that logging object WithEvents ... that they all get an event notification when your master app posts ... My master app is trying ... I copied this error handler from my existing code. ...
    (microsoft.public.vb.general.discussion)
  • Re: Subscript out of range, obvious?
    ... All your client apps could declare that logging object WithEvents ... that they all get an event notification when your master app posts ... My master app is trying ... I copied this error handler from my existing code. ...
    (microsoft.public.vb.general.discussion)
  • Re: Subscript out of range, obvious?
    ... All your client apps could declare that logging object WithEvents ... that they all get an event notification when your master app posts ... My master app is trying ... I copied this error handler from my existing code. ...
    (microsoft.public.vb.general.discussion)
  • Re: Extremely slow debugging performance in VS2003 with interop
    ... in the debugger now executes CreateInstance in 12 secs instead of 45. ... However, the second time I run the app, I'm back ... to 45 seconds every first time I run the app in the debugger. ... Here is the 12 second output: ...
    (microsoft.public.vsnet.debugging)
  • Re: Subscript out of range, obvious?
    ... All your client apps could declare that logging object WithEvents so ... My master app is trying to ... I'm trying to understand and apply your error handler ideas from above. ...
    (microsoft.public.vb.general.discussion)