473,883 Members | 1,686 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 4939
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
3429
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
1562
by: john | last post by:
is there a .net object that lets me use the http verbs like get, put, post?
3
15767
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
2499
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
2364
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
3893
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
6939
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
2941
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
3715
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
9938
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9791
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,...
0
11140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10742
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10414
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
7971
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
7125
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();...
2
4218
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3232
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.