Question WebClient throws Exception if there are more than 2 headers

Robert_Zenz

Well-known member
Joined
Jun 3, 2008
Messages
503
Location
Vienna, Austria
Programming Experience
3-5
Hello.

I have a problem with the System.Net.WebClient . I'm using it to send POST-Data to an php site and receving the site (which has changed 'cause of this data..whatever). This works fine...but the moment I add more than two headers (Weblcient.Headers.add()) it throws the following Exception (translated):

VB.NET:
This header must be changed with the corresponding property. Parametername: name

It throws this exception when I call UploadString...anybody an idea what this is?

Thanks in advance,
Bobby
 
It means you're trying to add a header through the Headers collection when this header has its own property that must be used. It could be the underlying WebRequest/HttpWebRequest that is throwing this error.
 
Hello

Sorry for my late answer.
You're right, I tried to add restricted headers as stated here:WebHeaderCollection Class (System.Net)

But instead of shouting the moment I add this headers the throws the exception the moment he tries to use the, of course, double existing headers.

Tahnks for the Info.

Bobby
 
Back
Top