signalr

How to prevent signalR errors from stopping further execution of javascript

安稳与你 提交于 2020-01-03 02:19:22
问题 I'm working on an asp.net mvc project where we use SignalR for real time connection in different views. Works great, apart from the fact that the execution of javascript stops if there's a problem with SignalR. Typically, this error would be a problem if my self hosting application is down, or other connection issues has occured. GET http://localhost:8081/signalr/hubs net::ERR_CONNECTION_REFUSED List:328 Uncaught TypeError: Cannot read property 'client' of null As mentioned, if this has

SignalR Authorization using Web API Token

与世无争的帅哥 提交于 2020-01-02 10:28:06
问题 I am attempting to authorize SignalR requests exactly using the sample project here AngularJS Authentication based on this project AngularJS Authentication using web tokens. The problem I am having is, to use SignalR authorization, I had to override the SignalR AuthorizeAttribute class as below: public class QueryStringBearerAuthorizeAttribute : AuthorizeAttribute { public override bool AuthorizeHubConnection(HubDescriptor hubDescriptor, IRequest request) { var token = request.QueryString.Get

How do you Resolve signalR v2.0 with StructureMap v2.6

时光毁灭记忆、已成空白 提交于 2020-01-02 09:32:18
问题 In Application_Start of Global.asax i have the following ObjectFactory.Initialize(cfg => { cfg.For<IDependencyResolver>().Singleton().Add<StructureMapDependencyResolver> (); }); My Interface for the Hub is public interface IDashboardHub { void Initialize(); } and my hub is as follows: public class DashboardHub : Hub, IDashboardHub { private readonly ICpeAccountService _accountService; public DashboardHub(ICpeAccountService service) { _accountService = service; } [Authorize] public void

How do you Resolve signalR v2.0 with StructureMap v2.6

匆匆过客 提交于 2020-01-02 09:32:07
问题 In Application_Start of Global.asax i have the following ObjectFactory.Initialize(cfg => { cfg.For<IDependencyResolver>().Singleton().Add<StructureMapDependencyResolver> (); }); My Interface for the Hub is public interface IDashboardHub { void Initialize(); } and my hub is as follows: public class DashboardHub : Hub, IDashboardHub { private readonly ICpeAccountService _accountService; public DashboardHub(ICpeAccountService service) { _accountService = service; } [Authorize] public void

Is it possible to return a pre-encoded JSON string in a SignalR hub method?

两盒软妹~` 提交于 2020-01-02 07:05:21
问题 In an MVC project, I have a method on a hub similar to this: public string Foo() { return DoCrazyThingThatReturnsJson(); } Unfortunately SignalR (or something) takes the encoded JSON string and happily encodes it, then returns it, so browser be like LOLWTF. Is there a way to skip this second encoding? 回答1: Looking at this here: We assume that any ArraySegment is already JSON serialized it seems like something like this may work (note that I haven't tried it, so no promises): string jsonString

Is it possible to return a pre-encoded JSON string in a SignalR hub method?

五迷三道 提交于 2020-01-02 07:05:13
问题 In an MVC project, I have a method on a hub similar to this: public string Foo() { return DoCrazyThingThatReturnsJson(); } Unfortunately SignalR (or something) takes the encoded JSON string and happily encodes it, then returns it, so browser be like LOLWTF. Is there a way to skip this second encoding? 回答1: Looking at this here: We assume that any ArraySegment is already JSON serialized it seems like something like this may work (note that I haven't tried it, so no promises): string jsonString

Signalr CORS issue

落爺英雄遲暮 提交于 2020-01-02 06:13:53
问题 On my server side I'm using web api 2 with signalr. On my client side I'm using angularjs. Here's the http request when I initiate the signalr connection: > GET > http://example.com/signalr/negotiate?clientProtocol=1.4&connectionData=%5B%7B%22name%22%3A%22main%22%7D%5D&_=1416702959615 HTTP/1.1 Host: mysite.net Connection: keep-alive Pragma: no-cache > Cache-Control: no-cache Accept: text/plain, */*; q=0.01 Origin: > http://lh:51408 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) > AppleWebKit

SignalR request pipeline, Hub lifetime

萝らか妹 提交于 2020-01-02 05:37:35
问题 I am starting on signalR with asp.net webapi, and I am trying to understand the whole signalR request/connection pipeline and what is the lifetime of the hub and who creates and dispose the hub instance (does it gets created on every communication between client and server?) One of the reason is that we need to understand how we should be using an IoC contain in signalR request scenario, how we control the lifetime of the dependency correct specifically the ISession or DBContext . 回答1: Hubs

Custom Headers and Signalr: Asp.Net MVC4 Web Api

别说谁变了你拦得住时间么 提交于 2020-01-02 05:00:29
问题 I am using signalr (version 2.0.0) in my asp.net mvc4 webapi project, Here to allow cross origin resource sharing, i use the following code in webconfig file <customHeaders> <add name="Access-Control-Allow-Origin" value="*" /> <remove name="X-Powered-By" /> </customHeaders> Here is the client side signalr code for receiving data from server: $(function () { var nodePublishingHub = $.connection.nodePublishingHub; nodePublishingHub.client.NodePublished = onNewMessage; $.connection.hub.error

SignalR Requests Throwing “Hub could not be resolved.”

拟墨画扇 提交于 2020-01-02 04:15:32
问题 I've been using SignalR since an early version and upgraded along the way however I have deployed my application to my Windows Server 2008 R2 production server and now the app crashes out with the " Hub could not be resolved." exception. edit: StackTrace Added: [InvalidOperationException: 'stockitems' Hub could not be resolved.] Microsoft.AspNet.SignalR.Hubs.HubManagerExtensions.EnsureHub(IHubManager hubManager, String hubName, IPerformanceCounter[] counters) +426 Microsoft.AspNet.SignalR