回答

4

這個簡單的替代解決這個問題

public class MyMultipartFormDataStreamProvider : MultipartFormDataStreamProvider 
{ 
    public MyMultipartFormDataStreamProvider(string path) : base(path) 
    { } 

    public override string GetLocalFileName(System.Net.Http.Headers.HttpContentHeaders headers) 
    { 
     // override the filename which is stored by the provider (by default is bodypart_x) 
     string originalFileName = headers.ContentDisposition.FileName.Trim('\"'); 

     return originalFileName; 
    } 
}