简体   繁体   中英

/signalr/hubs 404 not found when deployed to local IIS server, works on IIS express + signalr 1.0

I'm programming an angularJS single-page application on ASP.net, using signalR to communicate with the server hosted on Windows Server. It works perfectly on IIS express through visual studio, but does not working when deployed on to local IIS (10.0). I've been trying to solve this issue for two days now, and I have gone absolutely nowhere with it. I also use a generated hub proxy. Here's what I've tried:

-Installed ASP.net

-Ensured all IIS/.NET features were installed on Windows Server

-Validated that the Application pool is .net 4.0 Integrated

Here's my startup class:

using System;
using System.Threading.Tasks;
using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(Quoting.Startup))]
namespace Quoting
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var hubConfiguration = new HubConfiguration();
            hubConfiguration.EnableDetailedErrors = true;
            hubConfiguration.EnableJavaScriptProxies = true;

            app.MapSignalR();
            System.Diagnostics.Debug.WriteLine("SignalR Mapped");
        }
    }
}

I have tried each of the following, plus every possible combination from older versions of MVC which is not what i'm even programming in...

<script src="/signalr/hubs"></script>
<script src="~/signalr/hubs"></script>
<script src="signalr/hubs"></script>
<script src="/hubs"></script>
<script src=".../signalr/hubs"></script>
<script src="{{appname}}/signalr/hubs"></script>

I have this in my web.config:

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

Jquery:

    <script src="Scripts/jquery-3.4.1.js"></script>
    <script src="Scripts/jquery.signalR-2.4.1.min.js"></script>
    <script src="Scripts/jquery.signalR-2.4.1.js"></script>
    <script src="/signalr/hubs"></script> //note: this is what works on IIS express

I'm pretty lost. When I enter in the browser 'localhost:port/signalr/hubs', I get a response on IIS express. However, doing so with my domain, '{domainname}/directory/signalr/hubs' gets 404 not found, and every single combination I can think of will also return 404.

Solved: My directory structure was listed so that IIS pointed to a folder called "Website", and in this folder I had sub directories for different web apps. When the app is placed in one of these subdirectories, startup.cs is not called when the website is opened. Thus I needed to change my code so that the single page application was simply in the 'Website' folder and could be routed to the seperate apps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM