I installed SignalR 2.0.2 to my MVC 4.5 Application by using package manager console. And I did the standard example for the connection configuration.
namespace SignalRPersistent
{
public class Startup
{
public void Configuration(IAppBuilder app)
{
app.MapSignalR("/echo");
}
}
}
The problem is MapSignalR method does not accept string, while compiling the error says that
Argument type string is not assignable to parameter type SignalRHubConfiguration. But I can see an overload method that accepts a string but it insists not to be compiled. What can be problem ?
But no need to worry, there is another way to add the SignalR Library to your application. The following are the steps for installing the library to your application. Click on "File" and Select "New Project". The "New Project" window opens up. In the left panel, select your preferred language and select "Web".
A SignalR connection starts as HTTP, and is then promoted to a WebSocket connection if available.
In the Add New Item dialog box, select the Visual C# | Web | SignalR node in the left pane, select SignalR Hub Class (v2) from the center pane, name the file StatisticsHub.cs and click Add. Replace the code in the StatisticsHub class with the following code.
When the method call executes, SignalR sends the method name and the parameter values to the client. If the client has a method that matches the name, that method is called and the parameter values are passed to it.
I changed the code like below and I started to work.
app.MapSignalR<ConnectionHub>("/echo");
ConnectionHub is the class that inherit from PersistentConnection. The examples on the internet does not require to specify the class but they didnt work for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With