2013-10-30 94 views
0

我在將表單發佈到MVC時遇到問題,但只有在網站託管在Azure內時纔有問題。當它在本地託管在IIS內部或計算模擬器內部時,它工作正常。爲什麼在MVC託管在Azure中時MultipartFormDataContent不起作用?

請求已發佈,但是表單中的字段未映射到操作的參數。

是否有什麼我需要做的天藍色部署時髦?

MultipartFormDataContent data = new MultipartFormDataContent(); 
if (!String.IsNullOrEmpty(about)) 
{ 
    data.Add(new StringContent(about), "about"); 
} 
data.Add(new StringContent(displayName), "displayName"); 
data.Add(new StringContent(name), "name"); 
data.Add(new StringContent(email), "email"); 
data.Add(new StringContent(phone), "phone"); 
data.Add(new StringContent(isPublic ? "true": "false"), "isPublic"); 
data.Add(new StringContent(isPrimary ? "true" : "false"), "isPrimaryProfile"); 
if (picture != null) 
{ 
    byte[] imageBytes = await picture.GetBtyeFromFile(); 
    string imageString = Convert.ToBase64String(imageBytes); 
    data.Add(new StringContent(imageString), "picture"); 
} 

Uri uri = new Uri(url, UriKind.Absolute); 
HttpResponseMessage responseMessage = await client.PostAsync(uri, data); 

在服務器端,一切似乎都正確到達。這裏是我拉出InputStream的身體:

--614f8827-0cfe-48a6-a819-e6e9acdccae0 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: form-data; name=displayName 

display 
--614f8827-0cfe-48a6-a819-e6e9acdccae0 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: form-data; name=name 

Test Seller Account 
--614f8827-0cfe-48a6-a819-e6e9acdccae0 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: form-data; name=email 

email 
--614f8827-0cfe-48a6-a819-e6e9acdccae0 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: form-data; name=phone 

phone 
--614f8827-0cfe-48a6-a819-e6e9acdccae0 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: form-data; name=isPublic 

false 
--614f8827-0cfe-48a6-a819-e6e9acdccae0 
Content-Type: text/plain; charset=utf-8 
Content-Disposition: form-data; name=isPrimaryProfile 

true 
--614f8827-0cfe-48a6-a819-e6e9acdccae0-- 

,並在標題:

ALL_RAW - Content-Length: 880 
Content-Type: multipart/form-data; boundary="614f8827-0cfe-48a6-a819-e6e9acdccae0" 
Host: [my server] 
+0

你有什麼錯誤? –

+0

好問題,我忘了補充一點。 – Steven

+0

它不會將發佈表單中的字段映射到操作的參數。 – Steven

回答

相關問題