Unexpected end of MIME multipart stream in web api RRS feed

  • Question

  • Unexpected end of MIME multipart stream. MIME multipart message is not complete error comming when override Stream GetStream method of MultipartFormDataStreamProvider. i am getting stream in GetStream method and encrypt it and returning it than it gives me this error(Unexpected end of MIME multipart stream).I have done all previous sloutions,but doesn't work. Here is my code -:

        var Savedfiledata = await Request.Content.ReadAsMultipartAsync(provider).ContinueWith(

                        (Task<CustomMultipartFormData> readTask) =>
                            CustomMultipartFormData CMF = readTask.Result;// Here Error is comming

                            // Create response containing information about the stored files.

                            return CMF.FileData.Select(fileData =>
                                FileInfo info = new FileInfo(fileData.LocalFileName);
                                ContentDispositionHeaderValue disposition = fileData.Headers.ContentDisposition;

                                string filename = (disposition != null && disposition.FileName != null) ? disposition.FileName : string.Empty;

                                CS_FileUpload FileObj = new CS_FileUpload()
                                    FileName = filename.Replace("\"", ""),
                                    FileUniqueName = info.Name,
                                    FileSize = (info.Length / 1024),
                                    FilePath = info.DirectoryName,
                                    FileType = info.Extension,
                                    InsertDate = info.LastWriteTimeUtc,

                                return FileObj;



    public override Stream GetStream(HttpContent filedata, HttpContentHeaders headers)

                Stream reqStream = filedata.ReadAsStreamAsync().Result;

                using (MemoryStream stream = new MemoryStream())
                    MemoryStream getEncBytes = Encrypt(stream, GenerateKey());
                    return getEncBytes;


    • Moved by Stanly Fan Tuesday, October 17, 2017 9:11 AM
    Saturday, October 14, 2017 5:54 PM

All replies

  • Hi Gajendra,

    According to your description, your issue is more related about Web API. And this forum is discussing and asking questions about the Windows Form and ClickOnce, it will be more appropriate to ask your question at Web API Forum.

    Thank you for your understanding.



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, October 16, 2017 2:36 AM