SignalR /signalr/hubs 404 Not Found

前端 未结 14 1310
时光说笑
时光说笑 2020-12-29 03:16

I am trying to deploy a SignalR site on IIS. Code all works fine in VS. But getting the 404 not found error trying to resolve signalr/hubs so far I have tri

相关标签:
14条回答
  • 2020-12-29 03:58

    Similar problem I had on IIS version, I fixed it by restarting AppPool, restart web and its working now.

    0 讨论(0)
  • 2020-12-29 03:58

    I had the same problem, it was an asp.net project using signalR, it worked properly before I published but when I hosted it in IIS, it didn't.

    After I inspected I realized the address /signalr/hubs is not correct, let me explain more, just do the following steps:

    1. Open up your web application in the browser (Using IIS), you see the interface you designed, yeah? now press ctrl+U or right click on the page an select View Page Source.

    2. You will see multiple links starting with <script> tag at the top of the page, find something like <script src="/signalr/hubs"></script> now click on it, if you are taken to the page which involves "404 - File or directory not found."you have some mistakes on defining address, find the true address and change the address in the address bar to observe the true result

    In my case I needed to add my project name at the start of the address, so I had to change the address from:

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

    to

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

    in which MoveShape was my project name, now after pressing ctrl+U in the browser and following previously told steps, you click on the link and this time you see the true result, the page show codes starting with:

    /*!
     * ASP.NET SignalR JavaScript Library v2.2.2
     * http://signalr.net/
     *
     * Copyright (c) .NET Foundation. All rights reserved.
     * Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
     *
     */
    

    yeah! that's it, it works properly, keep in mind that it had no problem when I was testing it using Visual studio but not after hosting in IIS, as others have recommended make a correct address by applying <%= ResolveUrl("~/") %> or other methods.

    0 讨论(0)
提交回复
热议问题