c# - SignalR 意外响应代码 : 500

标签 c# json signalr signalr-hub

当我使用

的 JsonSerializer 选项时
_connection.JsonSerializer.TypeNameHandling = TypeNameHandling.All

我在 _connection.Start() 上遇到错误 {"StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:\r\n{\r\n Date: Tue, 04 Mar 2014 12:26: 26 GMT\r\n 服务器:Microsoft-HTTPAPI/2.0\r\n 内容长度:0\r\n}"

当我使用这个选项时,一切正常 _connection.JsonSerializer.TypeNameHandling = TypeNameHandling.Auto

最佳答案

您需要为默认关闭的服务器启用详细错误。我只在 Debug模式下启用它们

[assembly: OwinStartup(typeof(Startup))]
namespace MvcProject.App_Start
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var hubConfiguration = new HubConfiguration();

#if DEBUG
            hubConfiguration.EnableDetailedErrors = true;
#endif
            app.MapSignalR(hubConfiguration);

然后错误应该很容易解释了。

同时检查您是否有修复此错误的 JSON.net 版本: JsonSerializer does not appear to respect TypeNameHandling property correctly

关于c# - SignalR 意外响应代码 : 500,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22171971/

相关文章:

asp.net - 将数据发送到各个客户端而不是使用 SignalR 中的 Clients.All

c# - 多个 Controller 之间的通用方法

c# - 将数字字符串转换为四舍五入的小数 (C#)

javascript - 为什么这在 IE 中失败?

python - 使用 Flask 正确重载 json 编码和解码

javascript - 是否可以在删除 "<"和 ">"的情况下插入工作 JavaScript?

javascript - 创建一组元素的新实例

c# - 我可以在 C# 中声明带有千位分隔符的常量整数吗?

c# - WPF AvalonEdit SQL xhsd 请求

javascript - 使用 underscore.js 处理 JSON 数据