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

查看:22
本文介绍了内部服务器错误 - 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);

自定义控制器以:

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 日星期五 17:37:57X-Powered-By: ASP.NET内容长度:36内容类型:应用程序/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() --- 从先前引发异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__26.MoveNext() --- 从先前引发异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 Microsoft.WindowsAzure.MobileServices.MobileServiceHttpClient.d__18.MoveNext() --- 从先前引发异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 在 Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__69.MoveNext() --- 堆栈跟踪从先前引发异常的位置结束 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) 在 Microsoft.WindowsAzure.MobileServices.MobileServiceClient.d__63 2.MoveNext() --- 从先前引发异常的位置结束堆栈跟踪 --- 在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() at Stonegaard_endless_runner.MainPage.d__7.MoveNext()" 字符串

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

解决方案建议

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

我明天试试这个.

推荐答案

解决方案是添加:

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天全站免登陆