I have a custom Http handler that controls HTTP POST and GET. I got a project running on a separate isolated server, now I need to put it into production ...
using (var client = new WebClient())
{
client.Credentials = CredentialCache.DefaultCredentials;
client.UploadFile("serverlocation:port", fileToUpload);
}
For some reason now that it’s being used client.UploadFile("", file);, that is, forcing HTTP POST
System.Net.WebException: The remote server returned an error: (417) Expectation failed.
at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
What could it be? I know the code works, so what else? Maybe the server is blocking HTTP POST requests?
I tried to add:
ServicePointManager.Expect100Continue = false;
But I did not succeed, although I am not 100% sure where this code should be before, I assume that before I use WebClient
Change 0:
I have read the following:
- , ": 100- ", 417 ( ) 100 (). , (, ), 100 () , .
, -, - .
1:
, 100-, , , , WebClient.UploadFile, :
POST http://XXX.XXX.XXX.XXX:8091/file.myhandledextension HTTP/1.1
Content-Type: multipart/form-data; boundary=---------------------8ccd1eb03f78bc2
Host: XXX.XXX.XXX.XXX:8091
Content-Length: 4492
Expect: 100-continue
, , , : ServicePointManager.Expect100Continue = false;. , .