Quantcast
Channel: ASP.NET Blog
Viewing all articles
Browse latest Browse all 7144

Use SignalR Sample Nuget package in VS2013 Preview MVC 5 Project

$
0
0

We received feedback that the current 1.2 version SignalR sample Nuget package doesn’t work in an MVC 5 project by default. Here are the repro steps and the necessary change to make it work.

1. Create a C# MVC 5 project in VS2013 Preview

clip_image002

clip_image004

2. Install Microsoft.AspNet.SignalR.Sample NuGet package

clip_image006

3. This installs SignalR package version 1.1.3. In the SignalR.Sample/StockTicker.html file, the script link still links to 1.1.2, so change it to 1.1.3 first.

<script src="../Scripts/jquery.signalR-1.1.3.js"></script>

4. Run the application (I was using windows 8.1 preview with IE11), and get a JavaScript error:

clip_image008

5. What happened here is due to a bug in the 1.1.0-beta2 release of the Microsoft.Owin.Host.SystemWeb package, which will be fixed in future release. To work around this, the best way is to upgrade SignalR 1.1.3 to the latest 2.0 beta2 release.

6. Read http://www.asp.net/vnext/overview/latest/release-notes#TOC13 to understand the migration process from SignalR 1.x to 2.0. Migrating the sample package is a little bit simpler. First, upgrade the SignalR NuGet package to 2.0 Beta2 (select Include Prerelease in the drop-down at the top of the dialog):

clip_image010

7. A readme.txt file pops up talking about the hub registration. Compile to see the expected error message:

clip_image012

8. Delete App_Start/RegisterHubs.cs as it’s no longer used

9. In the root startup.cs file, add app.MapHubs(); in the Configuration method.

clip_image013

10. Change SignalR.Sample/StockTicker.html script link to 2.0

<script src="../Scripts/jquery.signalR-2.0.0-beta2.js"></script>

11. Run the html page, now you see that the SignalR sample works correctly.

clip_image014

The StockTicker sample package is open sourced at https://github.com/SignalR/SignalR-StockTicker. Currently it supports 1.x only, as SignalR 2.0 has not reached RTM yet. The sample will probably get updated by SignalR 2.0 RTM time.


Viewing all articles
Browse latest Browse all 7144

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>