2
votes

SignalR Requires Owin Startup Class, but my application works with Global.asax class.

public class Startup
{
   public void Configuration(IAppBuilder app)
   {
      app.MapSignalR();
   }
}

if I add the startup class, my asp MVC project will have two start classes (global and startup), is it OK? or I should only apply one of them and move my global class to startup class?

1

1 Answers

3
votes

You can mark which class in an assembly will be automatically used by Owin in the startup.

In my example, I declared it in the Startup and pointed to it using OwinStartup e.g.

using Microsoft.AspNet.SignalR;
using Microsoft.Owin;
using System.Net;
[assembly: OwinStartup(typeof(YourProject.Startup))]


namespace YourProject
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            var hubConfiguration = new HubConfiguration
            {
                EnableDetailedErrors = true
            };
            app.MapSignalR(hubConfiguration);
        }
    }
}

If you are using Owin, you must use the Startup class instead of the Global.asax.