gpt4 book ai didi

azure - 内部服务器错误 - Azure 应用服务自定义 Controller

转载 作者:行者123 更新时间:2023-12-02 23:49:14 25 4
gpt4 key购买 nike

我有一个 Azure 移动应用服务(不是旧的移动服务),带有多个自定义 Controller ,并且流程运行良好。

今天发生了关于内部服务器错误的错误。

我附加了调试器并逐步执行代码, Controller 到达末尾,没有任何错误,并返回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);

自定义 Controller 结尾为:

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

我已经验证所有变量都已初始化。 UserDTO 类型是从同一个可移植库引用的。有人能提示我如何找到此错误的原因吗? Controller 之前一直工作,没有任何改变。

一般错误消息

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

回应

{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 " 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

解决方案建议

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

我明天会尝试这个。

最佳答案

解决方案是添加:

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

ConfigureMobileApp 方法中的 Startup.MobileApp.cs

关于azure - 内部服务器错误 - Azure 应用服务自定义 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39797262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com