4.23Setting the Operation Before Adding Form Item Content
Created on Aug 17, 2026~1 min read
Before adding a HttpContent instance to a MultipartFormDataContent object, you can perform some preprocessing operations. For example, when integrating with certain object storage services (such as Alibaba Cloud OSS), you may need to remove the Content-Type setting (the framework has built in this operation).
HttpRequestBuilder.Post("https://furion.net") .SetMultipartContent(multipart => { multipart.SetBoundary("--------------------------") .AddFormItem("1", "id") .AddFormItem("Furion", "name") .SetOnPreAddContent((content, name) => // The delegate parameter type is: Action<HttpContent, string> { content.Headers.ContentType = null; }); });Note: The SetOnPreAddContent method supports being called multiple times; the results of each call accumulate.