8
votes

I've just started using SignalR with C#, seems intresting.

I've created an ASP.NET Empty Web Application and followed the tutorial mentioned below

I found Getting Started with SignalR tutorial on MSDN.

I've done all the steps mentioned in the tutorial. It seems to work on my local machine when it is being run on ASP.NET Development Server.

But when i Deploy the project to my IIS7, it doesnot work.

When i checked with the fiddler, it has the results of 404 on all the scripts files included into the html page.

Here is what the fiddler has shown enter image description here

Even i've found some suggestions from the posts on StackOverflow, which doesnot seem to work when i change my web.config file as well.

finally i've modified my web.config according to the FAQ's of SignalR.

Here is my web.config file:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
    </modules>
  </system.webServer>

</configuration>

Global.asax file:

public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            // Register the default hubs route: ~/signalr/hubs 
            RouteTable.Routes.MapHubs();
        }
        // Rest of the Methods(Session_Start,Application_BeginRequest..) are empty
     }

I've also changed

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

to

<script type="text/javascript" src='<%= ResolveClientUrl("~/signalr/hubs") %>'></script>

and

<script type="text/javascript" src='<%= ResolveUrl("~/signalr/hubs") %>'></script>

None of them seem to work either.

Do not hesitate to ask if any information required.

Any help would be appreciated


Update

As per the Aron suggestion, the following change is made to the Global.asax file

 RouteTable.Routes.IgnoreRoute("Scripts/");

and now, the jQuery scripts seems to be loading and working as well.

Here is the updated error message when hosted on IIS, its from the Console tab of the Browser window.

SCRIPT5022: SignalR: Error loading hubs. Ensure your hubs reference is correct, e.g. <script src='/signalr/hubs'></script>.
3
Please include your Global.asax.csAron
Does MVC work on this server?davidfowl
Try adding RouteTable.Routes.IgnoreRoute("Scripts/"); to your global.asaxAron
@dfowler I would assume so, given that its localhost.Aron
I wouldn't assume anything. It's really a yes or no question. SignalR uses a route in ASP.NET and if routing isn't working then things like MVC wouldn't work either (hence the question).davidfowl

3 Answers

1
votes

There may have been problem with your IIS settings. Please try adding MIME type for .js extension. Refer this link

1
votes

404 error may occure when IIS could not handle extension less url

http://support.microsoft.com/kb/980368

0
votes

The MSDN article demonstrates how to create SignalR applications in version 2.0. But you use signalr 1.0 and probably older verstion of visual studio. upgrade the visual studio and use nugget package manager to add signalr 2.0 requirements to your project. I think as a first try it is better to use asp.net web application instead of MVC ( as MSDN article ). So you will not have routing problem. I could run the sample with no problem.