473,698 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HTTP Post and HttpWebRequest object

We have implemented a 'HTTP Post' client in C# that posts Xml documents to a
webserver. This is working fine if the post rate is one post for every 20
seconds. But if the post rate is increased to one post for every 10 seconds
the client start getting error 403 'forbidden' from the webserver after a
short period of time. The webserver is IIS. The choking of the client/server
communication when doing high frequency posting is due to that we create a
new HttpWebRequest object for each post. We have tried to reuse the
HttpWebRequest object but with no success. Only if using 'HTTP Get' are we
able to resue the HttpWebRequest object and able to 'Get' one document per
second. But also for 'Http Get' we observe the same behavior with the
client/server communication choking when creating a new HttpWebRequest object
for each 'HTTP Get'. I.e. the 'HTTP Get' behavior led us to belive that it is
the recreation of a HttpWebRequest object for each request/post that is the
problem.

We need a way to reuse the HttpWebRequest object for 'HTTP Post' or a more
light weight creation of the HttpWebRequest objects so that the client is
able to post one document per seconds for an extensive period of time.

Is this a know problem?

What is the best practice to do high frequency HTTP Post's using C# and IIS?

regards, /jansenh
May 28 '06 #1
3 4916
I think you should see IIS Log file first, this will give you insight into
exact problem. But I can advise you few thingsL
This kind of error sometime occurs when you do HTTP Protocol Violation. This
can be due to the incorrect or incomplete UserAgent header. Try this line

request.UserAge nt="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET
CLR 1.1.4322)"

Moreover HTTP protocol violation can be ignored, if you specify
UseUnsafeHeader Parsing=true in the configuration file.
HttpWebRequest. UseUnsafeHeader Parsing property is internal and read-only and
can't be changed for particular instance of HttpWebRequest.

If you feel that my post help you please provide feedback for me.
"JansenH" wrote:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a
webserver. This is working fine if the post rate is one post for every 20
seconds. But if the post rate is increased to one post for every 10 seconds
the client start getting error 403 'forbidden' from the webserver after a
short period of time. The webserver is IIS. The choking of the client/server
communication when doing high frequency posting is due to that we create a
new HttpWebRequest object for each post. We have tried to reuse the
HttpWebRequest object but with no success. Only if using 'HTTP Get' are we
able to resue the HttpWebRequest object and able to 'Get' one document per
second. But also for 'Http Get' we observe the same behavior with the
client/server communication choking when creating a new HttpWebRequest object
for each 'HTTP Get'. I.e. the 'HTTP Get' behavior led us to belive that it is
the recreation of a HttpWebRequest object for each request/post that is the
problem.

We need a way to reuse the HttpWebRequest object for 'HTTP Post' or a more
light weight creation of the HttpWebRequest objects so that the client is
able to post one document per seconds for an extensive period of time.

Is this a know problem?

What is the best practice to do high frequency HTTP Post's using C# and IIS?

regards, /jansenh

May 28 '06 #2
Thus wrote jansenh,
We have implemented a 'HTTP Post' client in C# that posts Xml
documents to a webserver. This is working fine if the post rate is one
post for every 20 seconds. But if the post rate is increased to one
post for every 10 seconds the client start getting error 403
'forbidden' from the webserver after a short period of time. The
webserver is IIS. The choking of the client/server communication when
doing high frequency posting is due to that we create a new
HttpWebRequest object for each post. We have tried to reuse the
HttpWebRequest object but with no success. Only if using 'HTTP Get'
are we able to resue the HttpWebRequest object and able to 'Get' one
document per second. But also for 'Http Get' we observe the same
behavior with the client/server communication choking when creating a
new HttpWebRequest object for each 'HTTP Get'. I.e. the 'HTTP Get'
behavior led us to belive that it is the recreation of a
HttpWebRequest object for each request/post that is the problem.

We need a way to reuse the HttpWebRequest object for 'HTTP Post' or a
more light weight creation of the HttpWebRequest objects so that the
client is able to post one document per seconds for an extensive
period of time.


I don't see why the number of actual HttpWebRequest instances has anything
to do with a server-side problem. Simply create one instance per request
-- that's the underlying model. Can you post your code?

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
May 31 '06 #3
Thus wrote Altaf,
I think you should see IIS Log file first, this will give you insight
into
exact problem. But I can advise you few thingsL
This kind of error sometime occurs when you do HTTP Protocol
Violation. This
can be due to the incorrect or incomplete UserAgent header. Try this
line
request.UserAge nt="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
.NET CLR 1.1.4322)"
Not providing a User-Agent header isn't a protocol violation. But it's true
that many web applications rely on this header, and blissfully crash if it's
not there ;-)
Moreover HTTP protocol violation can be ignored, if you specify
UseUnsafeHeader Parsing=true in the configuration file.
HttpWebRequest. UseUnsafeHeader Parsing property is internal and
read-only and can't be changed for particular instance of
HttpWebRequest.


If there was a protocol violation, the OP should receive a WebException.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
May 31 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3408
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not establish secure channel for SSL/TLS" private void mainHttpCalls(string postData) { HttpWebRequest objRequest1 ; HttpWebRequest objRequest2 ;
3
1553
by: john | last post by:
is there a .net object that lets me use the http verbs like get, put, post?
3
15753
by: ME | last post by:
Hi; I am getting "Unhandled Exception: System.Net.WebException: The remote server returned an erro r: (401) Unauthorized." when I am trying to get a page via post. Code follows...
1
2487
by: Juan Dent | last post by:
Hi, The Request.SaveAs method stores in a file the complete HTTP request including the HttpVersion. However when I try to reproduce in memory the same thing, I cannot find the "HTTP/1.1" anywhere. I looked around and found a class called HttpWorkerRequest which has a method called GetHttpVersion() which returns the exact thing I am missing. However, I can't see how to get at the HttpWorkerRequest from a Page or from the HttpApplication.
1
2357
by: Dave Brown | last post by:
I am attempting to post to a url (https://FakeURL/logon.asp) using the HttpWebRequest class. The response for a succesful post will contain the html for the logon user's default page. We've accomplished this in the past utilizing the ServerXMLHTTP object. When I try an equivalent? post utilizing the HttpWebRequest class, the response contains the html for logon.asp (the same page that was posted to), which indicates to me that in some...
0
3876
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use tools like ieHTTPHeaders v1.6, and I perform a normal login (using the normal website), I see that the viewstate is __VIEWSTATE=dDwxMzU4OTE3NTA2Ozs%2BTK88jS63JXN181X3N8zKivua8co%3D&txt_username=xxx&txt_password=xxxxxx&btn_login=Login. When I...
3
6923
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication as per RFC 2617 (http://www.faqs.org/rfcs/rfc2617.html). My attempts to authenticate are failing. The server requires the header to be present with the request. For security reasons, it will not reply in any way if the header is not present. ...
2
2929
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am using ASP.Net 2.0 and VB.Net (although C#is ok also). I want to create an object/method/function that will take a URL as an input parameter and then return all of the HTML in that page. I also want to return the HTTP header information (response object). Does anyone have an insight as to any code samples or .Net objects I would use to accomplish this?
1
3697
by: ERobishaw | last post by:
Using Winform app writing a HTTP Post using the following... on the server side, I get no form fields. Request.Form.AllKeys.Length = 0. If I put the field/value paris in the URL I can use Request to retrieve the values, but POST doesn't work. There is NO Proxy... the only thing I can think is that ASP.NET is somehow filtering out the page because I'm obviously not posting the viewstate??? Seems like there was some setting for this,...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4371
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.