Tag: self hosting

ASP.NET MVC应用程序的自托管

我有一个完整的ASP.NET MVC应用程序(由5个程序集组成,.NET 4.5.1,ASP.NET MVC 5.2.2),它在Visual Studio(使用IISExpress)中运行良好。 我现在想要一个控制台应用程序,它接受MVC应用程序并托管它(自托管)。 我尝试使用Microsoft.Owin.Host.HttpListener和Nancy.Owin但是当我得到404页面时,我的配置缺少映射到我的MVC应用程序。 我有 public class Startup { public void Configuration(IAppBuilder app) { app.UseNancy(); } } 和 static void Main(string[] args) { StartOptions so = new StartOptions(“http://localhost:9000/”); using (WebApp.Start(so)) { Console.WriteLine(“Press Enter to Exit”); Console.ReadLine(); } } 但显然MyMvcApplication从正在运行的MVC应用程序中使用MyMvcApplication的配置。 怎么做? 或者如何自我托管呢? 我在网上找到的答案是指旧版本,我希望今天能有更简单的方法。