Ich möchte meine Lösung so ändern, dass sie unter einer selbst gehosteten OWIN-Instanz ausgeführt wird, aber ich benötige sie auch unter http://localhost, wenn nötig.Self-Hostable und IIS-hostable OWIN-Projekt
Wie sollte ich meine Startup-Klasse strukturieren, um von beiden erkannt zu werden?
Derzeit habe ich das Web-API-Projekt als Konsolenanwendung mit der Projekt-URL als http://localhost:2746 und dies ist mein Startklasse:
[assembly: OwinStartup(typeof(Startup))]
namespace Books
{
public class Startup
{
public static void Main(string[] args)
{
const int port = 2746;
var url = $"http://localhost:{port}/";
using (WebApp.Start<Startup>(new StartOptions(url) { ServerFactory = "Microsoft.Owin.Host.HttpListener" }))
{
var client = new HttpClient { BaseAddress = new Uri(url) };
Console.ReadLine();
}
}
public void Configuration(IAppBuilder app)
{
HttpConfiguration httpConfiguration = new HttpConfiguration();
WebApiConfig.Register(httpConfiguration);
app.Use<CustomExceptionMiddleware>().UseWebApi(httpConfiguration);
app.UseFileServer(StaticFileConfig.Build());
}
}
}
ich dies auch in der web.config habe:
<add key="owin:AutomaticAppStartup" value="false" />