我想启动2个或更多的webApp。我如何在.NET中做到这一点?我是C#和.NET的纽比。
class Program
{
static void Main(string[] args)
{
launchService("localhost:4234");
launchService("localhost:4265");
}
public static void launchService(Component component)
{
using (WebApp.Start<Startup>(component.Url()))
{
Console.WriteLine("Running on {0}", component.Url());
Console.WriteLine("Press enter to exit");
Console.ReadLine();
}
}
}发布于 2015-08-02 06:14:23
这应该是如下几点:
class Program
{
static IDisposable app1;
static IDisposable app2;
static void Main(string[] args)
{
launchServices("http://localhost:4234", "http://localhost:4265");
Console.ReadLine();
app1.Dispose();
app2.Dispose();
}
public static void launchServices(string url1, string url2)
{
app1 = WebApp.Start<StartupApp1>(url1);
app2 = WebApp.Start<StartupApp2>(url2);
}
}以下链接可能会进一步帮助您:
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/use-owin-to-self-host-web-api
OWIN cannot run multiple apps in isolation using webapp.start
注意:上面的代码可能有一些编译错误/输入错误,因为我刚刚使用IPad输入了它。
https://stackoverflow.com/questions/31767188
复制相似问题