سؤال

I have a mvc3 based web service which uses Ninject to manage its action filters, which all works fine. However now I am having to implement a SignalR hub into the mix and ideally want to re-use the existing action filters on these new hubs if possible.

One of the most important filters is the CookieAuthentication filter, which basically checks that a given request contains the right authentication cookie, if the cookie is not present or valid it sets the filtercontext.result object to a custom UnauthorisedResult object. So in this example are you able to use this functionality as SignalR to my knowledge has no idea about action results so not sure if it would automatically cancel requests etc.

I have tried googling but cannot find much info on the topic, I assume you cannot intermingle them as both frameworks only share the underlying ASP framework not the MVC framework.

هل كانت مفيدة؟

المحلول

You can't. ActionFilters are for MVC only and don't run when using SignalR. The only common ground (as you realize) is ASP.NET itself. That means you can write an HttpModule but not an action filter.

You can learn more about SignalR security here: http://www.asp.net/signalr/overview/security

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top