Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Signalr/Hub not loading in IIS 7 but working correctly in Visual Studio

I am working on a Web Application on the Asp .Net 4.0 framework that uses SignalR, having installed it from the Nuget package. When I debug or run the application without debugging locally it works correctly. However, when it is deployed to the production server it is unable to find the signal/hubs file that is being dynamically injected into the httphandlers. Due to it's dynamic nature it has to be created on the fly, so I can't just copy the working file into the project either.

I have tried the following methods of loading the file:

<script src="/signalr/hubs" type="text/javascript"></script> <script src="signalr/hubs" type="text/javascript"></script> 

And in the code behind:

ScriptManager.GetCurrent(Page).Scripts.Add(new ScriptReference("~/signalr/hubs")); 

All of these work locally but not on the server. The path that is rendered in the html looks correct, but there is no file there, delivering a 404 error. If it matters, the server has given the application Full Trust and the application is being run as an application under another site in IIS that uses a subdomain.

like image 288
PCasagrande Avatar asked Nov 08 '11 15:11

PCasagrande


People also ask

Does SignalR require IIS?

Supported server IIS versions IIS Express should be used on client operating systems. Also note that for SignalR to use WebSocket, IIS 8 or IIS 8 Express must be used, the server must be using Windows 8, Windows Server 2012, or later, and WebSocket must be enabled in IIS.

Does SignalR require Websockets?

SignalR uses the new WebSocket transport where available and falls back to older transports where necessary. While you could certainly write your app using WebSocket directly, using SignalR means that a lot of the extra functionality you would need to implement is already done for you.

Where can I host a SignalR?

A SignalR server is usually hosted in an ASP.NET application in IIS, but it can also be self-hosted (such as in a console application or Windows service) using the self-host library. This library, like all of SignalR 2, is built on OWIN (Open Web Interface for . NET).


2 Answers

The problem was solved by setting the following flags in the web.config.

<configuration>     <system.webServer>         <validation validateIntegratedModeConfiguration="false" />         <modules runAllManagedModulesForAllRequests="true">         </modules>     </system.webServer> </configuration> 

For some reason Nuget did not set these values for Elmah or SignalR

like image 75
PCasagrande Avatar answered Oct 03 '22 08:10

PCasagrande


I was facing a similar issue, I just changed the /signalr/hubs to /virtualDirectoryName/signalr/hubs and it worked.

like image 35
Girish Sakhare Avatar answered Oct 03 '22 08:10

Girish Sakhare