c#SignalR一次发送最大数据量

c# Signalr MessageSize默认是64K 大小,设为NULL即禁用这个限制 ,自己也可以按需求改为自己需要的大小

复制代码
 1 public class Startup
 2     {
 3         public void Configuration(IAppBuilder app)
 4         {
 5             //// 有关如何配置应用程序的详细信息,请访问 http://go.microsoft.com/fwlink/?LinkID=316888
 6             ////设置可以跨域访问
 7             //app.UseCors (Microsoft.Owin.Cors.CorsOptions.AllowAll);
 8             ////映射到默认的管理
 9             ////var hubConfiguration = new HubConfiguration();
10             ////hubConfiguration.EnableDetailedErrors = true;
11             ////app.MapSignalR ("/signalr", hubConfiguration);
12             //app.MapSignalR();
13            
14             app.Map("/signalr", map =>
15             {
16                 // Setup the CORS middleware to run before SignalR.
17                 // By default this will allow all origins. You can 
18                 // configure the set of origins and/or http verbs by
19                 // providing a cors options with a different policy.
20                 map.UseCors(CorsOptions.AllowAll);
21         
22                 var hubConfiguration = new HubConfiguration
23                 {
24                     EnableJSONP = true,
25                     EnableJavaScriptProxies = true,
26                     EnableDetailedErrors = true,
27                   
28                     // You can enable JSONP by uncommenting line below.
29                     // JSONP requests are insecure but some older browsers (and some
30                     // versions of IE) require JSONP to work cross domain
31                     // EnableJSONP = true
32                 };
33                 // Run the SignalR pipeline. We're not using MapSignalR
34                 // since this branch already runs under the "/signalr"
35                 // path.
36                 //最大数据量限制取消
37                 GlobalHost.Configuration.MaxIncomingWebSocketMessageSize = null;
38                 map.RunSignalR(hubConfiguration);
39             });
40         }
41     }
复制代码

默认数据缓冲区大小设置 GlobalHost.Configuration.DefaultMessageBufferSize = 1024

posted @   未风  阅读(1898)  评论(1编辑  收藏  举报
编辑推荐:
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
点击右上角即可分享
微信分享提示