内部服务器错误-Azure应用服务自定义控制器 [英] Internal Server Error - Azure App Service Custom Controller

查看:78
本文介绍了内部服务器错误-Azure应用服务自定义控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure移动应用程序服务(不是旧的移动服务),带有多个自定义控制器,并且流程运行完美.

I have a Azure Mobile App Service (not old mobileservice), with multiple custom controllers, and the flow works perfectly.

今天发生了关于Internal Server Error的错误.

Today an error occurred about Internal Server Error.

我在调试器上附加了逐步的代码,然后控制器走到尽头,没有任何错误,并击中了返回Ok.因此,我无法找到根.但是客户端然后得到一个错误,即内部服务器错误.

I attached the debugger an stepped through the code, and the controller gets to the end without any errors and hits the return Ok. Therefore I have not been able to find the root. But the client then gets the error that there is an internal server error.

我进行服务器呼叫,例如:

I make a server call like:

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

自定义控制器的结尾为:

The custom controller ends with:

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

我已验证所有变量都已初始化.类型UserDTO是从同一Portable Library引用的.有人可以暗示我如何找到此错误的原因吗?控制器之前一直工作,没有任何更改.

I have verified that all the variables are initialized. The Type UserDTO is referenced from the same Portable Library. Can anybody hint how I can find the cause of this error? The controller has worked before without any changes.

一般错误消息

请求无法完成.(内部服务器错误)"字符串

"The request could not be completed. (Internal Server Error)" string

响应

{StatusCode:500,ReasonPhrase:内部服务器错误",版本:1.1,内容:System.Net.Http.StreamContent,标头: { 伺服器:Microsoft-IIS/8.0 日期:2016年9月30日星期五,格林尼治标准时间 X-Powered-by:ASP.NET 内容长度:36 内容类型:application/json;字符集= utf-8 }} System.Net.Http.HttpResponseMessage

{StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Server: Microsoft-IIS/8.0 Date: Fri, 30 Sep 2016 17:37:57 GMT X-Powered-By: ASP.NET Content-Length: 36 Content-Type: application/json; charset=utf-8 }} System.Net.Http.HttpResponseMessage

堆栈

StackTrace",位于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. Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__69.MoveNext()\ r \ n处的CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n-从上次引发异常的位置开始的堆栈跟踪--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__63 2. MoveNext()\ r \ n ---从上一个引发异常的位置开始的堆栈结束跟踪--- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)\ r \ n在System.Runtime .CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)\ r \ n在System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\ r \ n在Stonegaard_endless_runner.MainPage.d__7.MoveNext()字符串

StackTrace " at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__24.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__26.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__69.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__63 2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at Stonegaard_endless_runner.MainPage.d__7.MoveNext()" string

解决方案建议

搜索Sid哦stackoverflow.并发现了2年前的一个问题. 已转换为Azure移动服务的Web API并未全部序列化属性

我明天会试试.

推荐答案

解决方案是添加:

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

Startup.MobileApp.cs在方法ConfigureMobileApp中.

这篇关于内部服务器错误-Azure应用服务自定义控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆