Adding a SignalR reference as a bundle

1,096 views
Skip to first unread message

Jonathan Readman

unread,
Mar 28, 2012, 10:50:03 AM3/28/12
to Cassette
Hi

I am trying to implement cassette in a project and have come into a
stumbling block when trying to load a bundle that is a reference to
signalR

In my Configure method I have the following line:

bundles.AddUrlWithAlias<ScriptBundle>("~/signalr/hubs", "signalr", b
=> b.AddReference("Scripts/jquery.signalR.js"));

And receive the following error on screen:

Reference error in bundle descriptor for "~/signalr". Cannot find "~/
signalr/Scripts/jquery.signalR.js".

I have removed the signalR implementation in said project and i am
able to compile and run and see cassette minimising my CSS and script
files so that leads me to believe I am not referencing my signalR path
correctly or am missing another configuration step.

Any help would be greatly appreciated!

Jonathan

Schabse Laks

unread,
Mar 28, 2012, 12:15:30 PM3/28/12
to cass...@googlegroups.com
As the error states, your relative path is being resolved relative to the base /signalr path.
Add ~/ to make it an absolute path.
--
Schabse Laks

Jonathan Readman

unread,
Mar 29, 2012, 5:48:49 AM3/29/12
to Cassette
Hi

Firstly thank you for the reply.

I done as you suggested and I get the page loading now...for your
reference i changed the line that adds the alias to the below:

bundles.AddUrlWithAlias<ScriptBundle>("~/signalr/hubs", "signalr", b
=> b.AddReference("~/Scripts/jquery.signalR.js"));

However, when the page loads and I suspect my element that calls the
signalR.js file I get a 404 not found exception because it is trying
to look at the following address:

http://localhost/~/signalr/hubs

Again removing the ~ from my line causes the original error. Any other
suggestions?

Jonathan
> @Schabse <http://twitter.com/Schabse> |
> StackOverflow<http://stackoverflow.com/users/34397/slaks>
>  | Blog <http://blog.slaks.net/>

Jonathan Readman

unread,
Mar 29, 2012, 6:49:52 AM3/29/12
to Cassette
Another possible issue here is that I am not referencing the file in
question in the correct way when adding the path to my script file.

I am doing this as below:

/// <reference path="/signalr/hubs" />

On Mar 29, 10:48 am, Jonathan Readman <jonathan.read...@gmail.com>

Chris Marisic

unread,
Mar 29, 2012, 11:55:52 AM3/29/12
to cass...@googlegroups.com
SignalR hubs are not javascript files, they are routes that return javascript. I'm not sure what kind of insanity it would take for you to integrate that into cassette

My only thoughts are some kind of static process, download the files from the web browser, then reference them directly into your project. I have no idea this would work, or if the javascript dynamically changes given certain things.

Andrew Davey

unread,
Mar 29, 2012, 1:59:27 PM3/29/12
to cass...@googlegroups.com
The call to AddUrlWithAlias needs to have an absolute URL i.e. "/app-virtual-dir/signalr/hubs"

Cassette does not apply any transformations to the URL.

Andrew Davey

unread,
Mar 29, 2012, 2:05:10 PM3/29/12
to cass...@googlegroups.com
Cassette won't do anything to the externally sourced content. It creates an "external" bundle object to represent it. It can still be referenced, and have references, but no minification, etc, will happen. It just produces a regular script/link tag in the HTML with the URL assigned to it.

That said, some crazy future version of Cassette could be adapted to fetch the URL during app start and use it as an asset that was then combined along with other local content too... Don't hold your breath on this feature though :) 

Maybe look at RequestReduce too, if you want something like this.
Reply all
Reply to author
Forward
0 new messages