2016-09-30 93 views
0

我有一個Azure移動應用服務(不是舊的移動服務),具有多個自定義控制器,並且流程完美工作。內部服務器錯誤 - Azure應用服務自定義控制器

今日發生的一條關於Internal Server Error的錯誤。

我附加了一個調試器,通過代碼的一步,並控制器到最後沒有任何錯誤,並返回Ok返回。所以我一直沒有找到根。但客戶端然後得到有內部服務器錯誤的錯誤。

我做的服務器呼叫,如:

return Ok(new UserDTO() 
{ 
    MicrosoftId = stable_sid, 
    Username = stable_users.Username, 
    playerNames = playerNames, 
    playerScores = playerInts, 
    isCreated = true, 
    bestScore = stable_users.bestRunnerScore, 
    statsInformation = _statsInformation, 
}); 

我已經驗證了所有的變量初始化:

DTO.UserDTO uploadImage = await ((App)Application.Current).MobileService.InvokeApiAsync<DTO.UsernameCheckDto, DTO.UserDTO>("user/blobStorageRetrieval", new DTO.UsernameCheckDto() { Username = ((App)Application.Current).InGameUserName }, System.Net.Http.HttpMethod.Post, null); 

定製控制與結束。 Type UserDTO引用來自相同的Portable Library。任何人都可以暗示我怎麼能找到這個錯誤的原因?控制器之前沒有任何更改就工作過。

一般錯誤消息

「的請求不能被完成(內部服務器錯誤)。」 串

響應

{的StatusCode:500,ReasonPhrase: '內部服務器錯誤',版本:1.1,內容:System.Net.Http.StreamContent,標題: { 服務器:Microsoft-IIS/8.0 日期:2016年9月30日17:37:57 GMT X-Powered-by-ASP.NET- Content-Length:36 Content-Type:application/json;字符集= UTF-8 }} System.Net.Http.HttpResponseMessage

堆棧跟蹤「在Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__24.MoveNext(個)\ r \ N-- - 從拋出異常的上一個位置結束堆棧跟蹤--- System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任務任務)中的\ r \ n \ System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任務任務) )\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__26.MoveNext()\ r \ n ---從以前位置拋出異常的堆棧跟蹤結束--- \ r \ n在System.Runtime.Co在Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__18.MoveNext()\ r \ n-上的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任務任務)\ r \ n上的mpilerServices.TaskAwaiter.ThrowForNonSuccess(任務任務) - 從以前位置拋出異常的堆棧跟蹤結束---在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任務任務)上的\ r \ n \ System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task任務)\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__69.MoveNext()\ r \ n ---從拋出異常的前一個位置的堆棧跟蹤結束---在System.Runtime的\ r \ n。 CompilerServices.TaskAwaiter.ThrowForNonSuccess(任務任務)\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__63上System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任務任務)\ r \ n 2。MoveNext()\ r \ n ---從之前的位置拋出異常的堆棧跟蹤結束--- System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任務任務)中的\ r \ n \ System.Runtime中的\ r \ n .CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任務任務)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult(個)\ r \ n在Stonegaard_endless_runner.MainPage.d__7.MoveNext()」字符串

解決方案

搜索希德哦計算器,而且發現從2年前的一個問題。Web API converted to Azure Mobile Service not serializing all properties

我會嘗試這個明天。

回答

1

解決的辦法是添加:

httpConfig.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include; 
httpConfig.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include; 

Startup.MobileApp.cs在方法ConfigureMobileApp