2

So I know this sounds odd, but I am looking to add a Global.asax file to my console application. Reason being is that it is self hosted with OWIN and in the self-hosted life cycle, the Global.asax is called just slightly before the Startup.cs file. The end goal is to add configuration settings to this file which are applied to SignalR and the only entry point for these configurations seems to be in the Global.asax (I have tried Startup.cs).

However, once I add a Global.asax file to my application, it is never called upon. Is there anything I can do to force the Global.asax file to be called before the Startup.cs file?

EDIT: Here are the particular configuration settings I am referring to. Namely, the DisconnectTimeout

Barry Tormey
  • 2,966
  • 4
  • 35
  • 55
  • 5
    `Barry Tormey` Global.asax file as far as my knowledge and understanding is used strictly for Web Applications.. perhaps you need to explain more in detail what you are trying to truly accomplish – MethodMan Jan 05 '15 at 13:43
  • you can configure your SignalR from Owin's Configuration. What are you really trying to accomplish? – Jonesopolis Jan 05 '15 at 13:45
  • Is this any help? http://stackoverflow.com/questions/20552359/convert-web-api-to-use-self-hosting – Jason Evans Jan 05 '15 at 13:46
  • To clairfy a bit more, it looks like the `Timeout` settings in SignalR are declared in the Global.asax file, not the Startup.cs file. Unless there is something I am missing and these settings can be configured from the Startup file. See https://github.com/SignalR/SignalR/wiki/Configuring-SignalR – Barry Tormey Jan 05 '15 at 13:46
  • There's this too : http://weblogs.asp.net/fredriknormen/get-started-by-using-asp-net-web-api-and-nancyfx-with-owin-katana – Jason Evans Jan 05 '15 at 13:47
  • 1
    This seems to be a duplicate question: http://stackoverflow.com/questions/27712784/signalr-self-host-disconnect-timeout-without-global-asax – Noel Jan 05 '15 at 13:48

1 Answers1

3

You should be able to configure your SignalR server in Startup

If I set the DisconnectTimeout like this

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.MapSignalR();
        GlobalHost.Configuration.DisconnectTimeout = new TimeSpan(0, 0, 20);
    }
}

I can see that the DisconnectTimeout in the negotiate response is 20

{
    "Url":"/signalr","ConnectionToken":"hYV7...5",
    "KeepAliveTimeout":13.3333332,
    "DisconnectTimeout":20.0,
    "TryWebSockets":true,
    "ProtocolVersion":"1.4",
    "TransportConnectTimeout":5.0,
    "LongPollDelay":0.0
}
Pawel
  • 31,342
  • 4
  • 73
  • 104