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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM