内部服务器错误 - Azure应用服务自定义控制器

时间:2016-09-30 17:49:27

标签: azure azure-web-sites

我有一个Azure移动应用服务(不是旧的移动服务),有多个自定义控制器,流程完美无缺。

今天发生了Internal Server Error的错误。

我在调试器中附加了代码,控制器在没有任何错误的情况下结束并点击返回Ok。因此我无法找到根。但是客户端会收到内部服务器错误的错误。

我打电话给服务器:

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);

自定义控制器以:

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

我已经确认所有变量都已初始化。 Type UserDTO是从同一Portable Library引用的。任何人都可以提示如何找到导致此错误的原因吗?控制器之前没有任何变化。

通用错误消息

  

&#34;请求无法完成。 (内部服务器错误)&#34;串

响应

  

{StatusCode:500,ReasonPhrase:&#39;内部服务器错误&#39;,版本:1.1,内容:System.Net.Http.StreamContent,标头:   {     服务器:Microsoft-IIS / 8.0     日期:2016年9月30日星期五17:37:57 GMT     X-Powered-By:ASP.NET     内容长度:36     Content-Type:application / json;字符集= utf-8的   System.Net.Http.HttpResponseMessage

  

StackTrace&#34;在Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__24.MoveNext()\ r \ n ---从抛出异常的上一个位置的堆栈跟踪结束--- \ 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.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__18.MoveNext()\ r \ n ---从抛出异常的上一个位置的堆栈跟踪结束--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.Task Awaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__69.MoveNext()\ r \ n ---从前一个引发异常的位置开始的堆栈跟踪--- \ r \ n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__63 2.MoveNext( )\ r \ n ---从抛出异常的上一个位置的堆栈跟踪结束---在System.Runtime.CompilerServices上的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n中的\ r \ n .TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n位于Stonegaard_endless_runner.MainPage.d__7.MoveNext()&#34;串

解决方案提案

搜索Sid哦stackoverflow。并在2年前发现了一个问题。 Web API converted to Azure Mobile Service not serializing all properties

明天我会试试。

1 个答案:

答案 0 :(得分:2)

解决方案是添加:

httpConfig.Formatters.JsonFormatter.SerializerSettings.DefaultValueHandling = Newtonsoft.Json.DefaultValueHandling.Include;
httpConfig.Formatters.JsonFormatter.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Include;
方法Startup.MobileApp.cs

ConfigureMobileApp