-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpClient uploading files with NTLM: An existing connection was forcibly closed by the remote host -- .NET Core 2.1/3.0 difference against .NET Framework #31133
Comments
Sounds very similar to another 'Expect: 100-continue' and Negotiate/NTLM bug we had. But I thought we fixed it in .NET Core 3.0. |
@Rookian .NET Core doesn't send 'Expect: 100-continue' by default (.NET Framework does). Can you try your scenario with manually adding 'Expect: 100-continue' to your HTTP request? Would like to see what difference that makes. Thanks. |
@davidsh Yes, .NET Core doesn't send Expect:100-continue. I now use: httpClient.DefaultRequestHeaders.ExpectContinue = true; HTTP/TCP Stream:
Error message:
If you need a pcap file or so let me know. |
Is this using .NET Core 2.1 or .NET Core 3.0. We've seen error like "" in 2.1. So, I'd be interested in seeing .NET Core 3.0 results using ExpectContinue=true.
Thanks. If the pcap file doesn't have any confidential information, then, yes, please zip it up and attach it. Otherwise, we'll need to figure out a different way for you to give us this information. |
This is using .NET Core 3.0. @davidsh If you need anything else let me know. |
That workaround works because it "warms up" the connection for Windows auth. Instead of a GET request, you can also send a HEAD request. It will be more performant since a server will send back a response to a HEAD requests with no response body payload. |
@davidsh , I believe this is related to the optimizations I mentioned. When using NTLM, .NET Framework sends a 0-byte content length as it knows there will be a challenge due to the passed credentials. The server will tolerate draining a certain amount of request but if the request is too big, it will close the connection. |
I know this is very old issue, but can somebody confirm if this is still broken and relevant? |
We try to upload a file to a windows hosted web server.
Using the Fullframework everything works fine.
We use the follwing code:
When we use the exact code in .NET Core we receive an error.
HTTP/TCP Stream for full framework:
HTTP/TCP Stream for .NET Core 3.0:
As you can see the full framework is sending 2 additional headers:
Authorization: NTLM
Expect: 100-continue
We also noticed that when we send a very small file or an empty byte array the authentication is working for .NET Core 3.0
Our workaround right now is to first send a small Get request to authenticate against the server and receive an authentication cookie and then upload the file. So all following requests just use the authentication cookie and no NTLM.
The text was updated successfully, but these errors were encountered: