The context object in the ASP. SignalR Hub

Source: Internet
Author: User

Original: The context object in ASP. SignalR Hub

The context in the hub

When you use a hub, you'll find that comparing persistent connection classes with fewer events like onconnectioned, in fact there is. We need to go to override.

This seems to find out what the problem is, remember that there are connectionid and request parameters in the persistent connection class, and there is nothing here??? If there's a need to get connectionid.

In fact, there is no need to worry about it, because the context object has been encapsulated for us, as can be seen in the base class Hubbase, which is the Hubcallercontext type

F12 to see what's in this class, um ConnectionID, Headers, QueryString ... and so on.

//    //Summary://represents the calling context of the client.      Public classHubcallercontext {//        //Summary://Initializes a new instance of the Microsoft.AspNet.SignalR.Hubs.HubCallerContext class. //        //Parameters://Request://the current HTTP request. //        //ConnectionID://The connection ID.          PublicHubcallercontext (Irequest request,stringConnectionID); protectedHubcallercontext (); //        //Summary://Gets the connection ID of the calling client. //        //return Result://the connection ID of the calling client.          Public Virtual stringConnectionID {Get; } //        //Summary://gets the header of the request. //        //return Result://the header of the request.          Public VirtualInamevaluecollection Headers {Get; } //        //Summary://gets the query string for the request. //        //return Result://the query string for the request.          Public VirtualInamevaluecollection QueryString {Get; } //        //Summary://gets the Microsoft.AspNet.SignalR.IRequest for the current HTTP request. //        //return Result://the Microsoft.AspNet.SignalR.IRequest of the current HTTP request.          Public VirtualIrequest Request {Get; } //        //Summary://gets the requested Cookie. //        //return Result://the requested Cookie.          Public Virtualidictionary<string, cookie> requestcookies {Get; } //        //Summary://gets the System.Security.Principal.IPrincipal of the request. //        //return Result://the requested System.Security.Principal.IPrincipal.          Public VirtualIPrincipal User {Get; } }

ASP. SignalR the context object in the hub

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.