I am trying to connect to a php apache 2.2.1 webservice like this:
protected override WebRequest GetWebRequest(Uri uri)
{
var req = base.GetWebRequest(uri);
var http = req as HttpWebRequest;
if (http != null)
{
http.Connection = "Close";
http.ServicePoint.Expect100Continue = false;
}
return req;
}
But I received an System.ArgumentException mean as following "Keep-Alive and Close cannot be set"(This message has been translated from Japanese).
I have no idea why this exception is thrown. I have searched in MSDN and there is an explanation like this Exception Condition: The value of Connection is set to Keep-alive or Close.. In this case my httpWebRequest.Connection is null.
Do you have any idea about the reason of this exception?