I'm self-hosting ASP.NET Web API and SignalR using OWIN. I start the server (on a console app) with this code:
using (WebApplication.Start<Startup>(url))
{
Console.WriteLine("Running...");
Console.ReadLine();
}
This works fine. But now I need to pass a parameter (an object) to the Startup
class. How can this be done?
The
WebApplication.Start
method has an overload that accepts aIServiceProvider
as parameter, so it is possible to inject the data I want.Now, on my
Startup
class I only need to create a constructor that receives the IMyInterface:You can use the
WebApp.Start Method (String, Action<IAppBuilder>)
overload.Example: