Developer forum

Forum » Development » Dynamicweb with SignalR

Dynamicweb with SignalR

Nuno Aguiar
Reply

Hi,

 

I am trying to use SignalR in Dynamicweb and started with Mikkel's example from the Tech Conference 2013. Both Dynamicweb and SignalR have been updated since then but I cannot get them to work.

 

Anyone has encountered problems with it?

 

Nuno


Replies

 
Morten Bengtson
Reply

What do you mean by "cannot get them to work"?

Do you get an error?

Are you using IIS 7 or 8?

 
Mario Santos
Reply

Hi Morten,

 

We follow the steps in readme file.

The RouteTable.Routes.MapHubs() is deprecated so we added a OwinStartup class, following this article:

http://www.asp.net/signalr/overview/signalr-20/getting-started-with-signalr-20/upgrading-signalr-1x-projects-to-20

 

We can compile the VS solution successfully, but in Dynamicweb we can only start if we add the appSettiing <add key="owin:AutomaticAppStartup" value="false" />.

 

I've attached the VS solution.

 

Mário

 

 
Marco Santos
Reply

Hello.

I think the problem is that it cannot find the signalr/hubs file that is managed by the framework. Let me tell you what I have done, and maybe you will be able to spot what went wrong.

- Created an empty web application in VS. Followed the steps to create a chat app (created a Startup class and a Hub class) as per one of the tutorials on the web. Changed the references for the scripts to correct the scripts references in the page I created to test the chat. Chat functionality works.

- Placed the DW application contents in the web site created in the previous step. After changing a few bits the web.config and removing the Startup class (conflicts with a DW class, which I presume is the equivalent startup class DW uses for its SignalR purposes), both the Admin site and the front end for DW work. My example page loads, but there is an 404 error for http://signalrchat.local.dynamicweb.pt/signalr/hubs.

The test page is at the root of the web site, and the references in the file are as follows:

    <script src="/Scripts/jquery-2.1.1.min.js"></script>

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

    <script src="signalr/hubs"></script>

What I am wondering is that the signalr/hubs is placed somewhere else because of DW configurations. Can you think of anything that I could try to get it working?

Marco

 
Marco Santos
Reply

Hello.

Just noticed another thing: a simple test app that I have for this works when I Run in IIS Express, but not on the local IIS.

Tried to see if the same thing happens on the DW project but cannot. It start the DW configuration process and gets stuck. IIS version on local machine is 7.5, by the way.

Marco

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Could it be that Dynamicweb is intercepting the request and returns a 404? Try to add the following code to your Global.asax:

 public void Application_OnPreRequestHandlerExecute(object sender, EventArgs e)
    {
      if (!HttpContext.Current.Request.Url.ToLower().Contains("signalr"))
      {
        GlobalAsaxHandler.Application_OnPreRequestHandlerExecute(sender, e);
      }
    }

(Code typed in this editor so it may not completely work)

This should bypass requests for all signalr URLs...

Imar

 
Morten Bengtson
Reply
This post has been marked as an answer

You don't need to change the Application_OnPreRequestHandlerExecute in order to make this work.

The sample application contains a notfication subscriber called "RouteHandler" which subscribes to the notification Standard.Application.AuthenticateRequest. Inside this it disables DWs URL handling by setting a property Handled = true on the event args.

I had forgotten all about this notification... it's very useful in cases like this :)

Anyway, I managed to get the sample app up and running, by doing this:

1) Upgrade to SignalR 2.1.0 (make sure you use the exact same versions of all dependencies that your target DW version uses).

2) Add this to web.config, appSettings:

<add key="owin:appStartup" value="Dynamicweb.Chat.Backend.Startup, Dynamicweb.Chat.Backend" />

3) Add this to web.config, runtime > assemblyBinding:

<dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>
<dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" />
</dependentAssembly>

 

Votes for this answer: 1

 

You must be logged in to post in the forum