SignalR /signalr/hubs 404 Not Found

前端 未结 14 1408
时光说笑
时光说笑 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:37

    I might be a little late but hope it helps someone. Make sure this code run on start.

     Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        RouteTable.Routes.MapHubs()
     End Sub
    

    Because I added a global.asax to my application and then a codebehind but put this in Global.asax file

     <%@ Application Language="VB" CodeBehind = "Global.asax.vb" %> /*This was wrong*/
    

    So when i tried to run the application, the Application_Start in my global.asax did not initialize the hub. that's why it couldn't resolve signalr/hubs

    fixed with this in my Global.asax

     <%@ Application Inherits="_Global" Language="VB" %>
    

    and this in my Global.asax.vb:

     Public Class _Global
         Inherits System.Web.HttpApplication
    

提交回复
热议问题