Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

404 error on signalr/hubs and on jquery scripts

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>.
like image 661
Karthik Chintala Avatar asked Mar 06 '13 09:03

Karthik Chintala


2 Answers

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

like image 190
touseefkhan4pk Avatar answered Nov 05 '22 14:11

touseefkhan4pk


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

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

like image 28
user3006075 Avatar answered Nov 05 '22 15:11

user3006075