Skip to content

HttpClient ContentDisposition Problem #98896

Answered by MihaZupan
CavidH asked this question in General
Discussion options

You must be logged in to vote

If there is something about the format of the Content-Disposition header value that your server does not understand, you should be able to manually add the exact value format you want via the existing TryAddWithoutValidation method.

Something like

using var formData = new MultipartFormDataContent();
var fileContent = new StreamContent(myStream);
formData.Add(fileContent, "file", file.FileName);
fileContent.Headers.Remove("Content-Disposition");
fileContent.Headers.TryAddWithoutValidation("Content-Disposition", "the custom value that you've validated to be safe to use because it won't be validated further");

cc: @dotnet/ncl

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@CavidH
Comment options

@MihaZupan
Comment options

@CavidH
Comment options

@CarnaViire
Comment options

@CavidH
Comment options

Answer selected by MihaZupan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants