httpwebrequest timing out

R

RP

Hi all, I have some code that does a basic form post to an .aspx page
submitting some XML in the body. This code used to work on my WIN2K server
running .net 1.0 sp2. Now since I have upgraded to SBS2003 running ISA2K as
a proxy and .net 1.1 it basically hangs and times out. Here is the code
snippet. Any ideas? ISA is configured in Integrated mode and all clients are
SecureNAT Clients not required to authenticate.

Private Function ProcessRequest(byval strbody as string) as string
Dim returnstr as string

Dim wp as new WebProxy("http://sterling--atl:8080/", true)
GlobalProxySelection.Select = wp

Dim h as httpwebrequest =
Ctype(WebRequest.Create("http://sterling--atl/public/tmk.aspx"),
httpwebrequest)
h.Proxy = wp
h.KeepAlive = false
h.timeout = 10000
h.method = "POST"
h.contentlength = strbody.length
h.contenttype = "application/x-www-form-urlencoded"

Dim sw as new streamwriter(h.getrequeststream())
sw.write(strbody)
sw.close()

Dim hr as httpwebresponse = Ctype(h.getresponse(), httpwebresponse) ' CODE
BREAKS HERE.
Dim sr as new streamreader(hr.getresponsestream())
returnstr = sr.readtoend()
sr.close()

funcend:
return returnstr
End Function

Please Help!!
 
R

RP

I switched the method to GET and it seems to be hitting it. Now why isnt
POST working? That is weird.

thanks
 
R

RP

OK. Narrowed it down even further. POST works with relatively small post
data like a string like "Hello World". With larger data I get the same time
out.
 
T

Tristan Kington [MSFT]

Depending on the client, try upgrading to the latest available IE security
patch, plus the following update:
http://support.microsoft.com/?id=831167

At the ISA end, you can try upgrading to Service Pack 1 (if you're not
already using it) and the Required Updates for Windows Server 2003:
http://www.microsoft.com/downloads/...87-5205-4779-b1ab-fc338283b2d9&DisplayLang=en

--

This posting is provided "AS IS" with no warranties, and confers no rights.

OK. Narrowed it down even further. POST works with relatively small post
data like a string like "Hello World". With larger data I get the same time
out.
 
R

RP

Tristan, on the server i am running sbs2003 premium so it comes with isa2k
sp1 and isa seems to be working ok. I am on laresr ie6 sp1 also. This code
was working fine on my earlier environment. Ofcourse I had no ISA then.

thanks!
 
J

Joerg Jooss

RP said:
Hi all, I have some code that does a basic form post to an .aspx page
submitting some XML in the body. This code used to work on my WIN2K
server running .net 1.0 sp2. Now since I have upgraded to SBS2003
running ISA2K as a proxy and .net 1.1 it basically hangs and times
out. Here is the code snippet. Any ideas? ISA is configured in
Integrated mode and all clients are SecureNAT Clients not required to
authenticate.

Private Function ProcessRequest(byval strbody as string) as string
Dim returnstr as string

Dim wp as new WebProxy("http://sterling--atl:8080/", true)
GlobalProxySelection.Select = wp

Dim h as httpwebrequest =
Ctype(WebRequest.Create("http://sterling--atl/public/tmk.aspx"),
httpwebrequest)
h.Proxy = wp
h.KeepAlive = false
h.timeout = 10000
h.method = "POST"
h.contentlength = strbody.length
h.contenttype = "application/x-www-form-urlencoded"

Dim sw as new streamwriter(h.getrequeststream())
sw.write(strbody)
sw.close()

[...]

You're using a StreamWriter instance that implicitly uses UTF-8 encoding.
Unless you're sending pure ASCII content in strBody, the content length will
be greater than strbody's length, since non-ASCII characters will use two
ore more bytes. Thus, your Content-Length header will advertise a wrong
value. Avoid StreamWriter here and encode manually:

public void PostForm(string url, string formData, string encoding) {
byte[] content = Encoding.GetEncoding(encoding).GetBytes(formData);
string contentType =
String.Format("application/x-www-form-urlencoded; charset={0}",
encoding);

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.Method = "POST";
request.ContentType = contentType;
request.ContentLength = content.Length;
// Do POST...
}

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top