I've been tasked with migrating our Asp.Net MVC4 application running on a Windows Server 2008 R2 server over to a Windows 2016 server.
It works as expected on the 2008 server, but when I attempt to access the site on the 2016 server, a 500 error pops up stating
[InvalidOperationException: 'NotificationHub' Hub could not be resolved.]
Microsoft.AspNet.SignalR.Hubs.HubManagerExtensions.EnsureHub(IHubManager hubManager, String hubName, IPerformanceCounter[] counters) +428
Microsoft.AspNet.SignalR.Infrastructure.ConnectionsManager.GetHubCOntext(String hubName) +295
RR.DAL.SRepository.<.cctor>b__6() +87
System.Lazy`1.CreateValue() +734
System.Lazy`1.LazyInitValue() +189
RR.MvcApplication.Application_Start() +748
[HttpException (0x80004005): 'NotificationHub' Hub could not be resolved.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +546
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +171
.....
Version Information: Microsoft .NET Framework Version: 4.0.30319; ASP.NET Version 4.8.4210.0
I have had no success so far with what I've discovered in other questions.
My hub class is marked as Public
The SignalR route is added before the other routes
My hub classes are in the same assembly as the application
I've made sure that my web configuration has the validation and managed modules configured
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
Ive configured extensionless URL's (carryover from the old server)
Our web.config targets 4.0 <compilation debug="true" targetFramework="4.0" />'
and the appplication pools on iis are all configured to use the 4.0 .net CLR versions
We are using Unity as well and the error occurs when registering and instance of our class that uses a hub
global.asax
container.RegisterInstance(typeof(ISRepository), SRepository.Instance, new ContainerControlledLifetimeManager());
SRepository.cs
namespace RR.DAL{
public class SRepository : ISRepository{
private readonly static Lazy<SRepository> _instance = new Lazy<SRepository>(() => new SRepository(GlobalHost.ConnectionManager.GetHubContext<NotificationHub>().Clients));
private SRepository(IHubConnectionContext clients){
Clients = clients;
}
public static SRepository Instance{
get{ return _instance.Value;}
}
private IHubConnectionContext Clients{get;set;}
NotificationHub.cs
public class NotificationHub: Hub
{
private readonly ISRepository _sRepository;
public NotificationHub(ISRepository sRepository)
{
_sRepository = sRepository;
}
I cant figure out why the application is crashing during the app_startup phase. I cant even view the /signalr/hubs page, it gives me the same error.
Any ideas?
The server is running IIS10, Windows Server 2016 with .Net Framework 4.6 The application is an MVC 4 .Net 4.0 and using SignalR v1.1.3
User contributions licensed under CC BY-SA 3.0