Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to implement SignalR with asmx webservice. The service is called from my front end application and my project is running. My first question is, should I create SignalR hub here or I have to make another application for the Hub and use that for realtime purpose?

And second question is,

public class MyHub1: Hub
{
    public bool ConnectUser(long userId)
    {
        UserManipulation Up = new UserManipulation();//its my class to process user//
        return Up.ConnectUser(userId, Context.ConnectionId);
    }
}
This is hub method to save the connection Id in database with the userid.

Now in asmx page, you know we have to create a [webmethod], so that I can call that method from front end. I want to create a webmethod which will call this hub method.

[WebMethod]
public bool ConnectUser(string UserId)
{
        SignalRHub.MyHub1 myhub = new SignalRHub.MyHub1();//SignalRHub is namespace//
        return myhub.ConnectUser(UserId);
}
But the context within the hub method getting null.

I don't know I'm in right way or not, but please help me how can I achieve the things to implement Hub not directly in front end, instead this type of service.


What I have tried:

I have written the code what I tried and where I'm stuck.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900