Blog.Common.Web.Extensions.InMemoryMultipartFormDataStreamProvider.ExecutePostProcessingAsync C# (CSharp) Method

ExecutePostProcessingAsync() public method

Read the non-file contents as form data.
public ExecutePostProcessingAsync ( ) : System.Threading.Tasks.Task
return System.Threading.Tasks.Task
        public override async Task ExecutePostProcessingAsync()
        {
            // Find instances of non-file HttpContents and read them asynchronously
            // to get the string content and then add that as form data
            for (int index = 0; index < Contents.Count; index++)
            {
                if (_isFormData[index])
                {
                    HttpContent formContent = Contents[index];
                    // Extract name from Content-Disposition header. We know from earlier that the header is present.
                    ContentDispositionHeaderValue contentDisposition = formContent.Headers.ContentDisposition;
                    string formFieldName = UnquoteToken(contentDisposition.Name) ?? String.Empty;

                    // Read the contents as string data and add to form data
                    string formFieldValue = await formContent.ReadAsStringAsync();
                    FormData.Add(formFieldName, formFieldValue);
                }
                else
                {
                    _fileContents.Add(Contents[index]);
                }
            }
        }
InMemoryMultipartFormDataStreamProvider