本文介绍了内部服务器错误-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.

一般错误消息

响应

堆栈

解决方案建议

搜索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应用服务自定义控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 00:40