如何从C#以编程方式启动ASP.NET Core Web-API?单击表单中的按钮后,API应该启动。
我已经通过Add -> Existing Project...
将我的API添加到我的解决方案中,但我不知道如何从其他项目启动它。
Web-API在.NET Core 2.0上运行,我想从使用.NET Framework 4的项目启动它
可能你正在寻找像this(link)这样的东西
dotnet run [-c|--configuration] [-f|--framework] [--force] [--launch-profile] [--no-build] [--no-dependencies]
[--no-launch-profile] [--no-restore] [-p|--project] [--runtime] [[--] [application arguments]]
dotnet run [-h | --help]
您还可以尝试将该应用程序作为Windows Service运行,并在单击时启动该服务。
这是一个展示WPF中ASP.NET Core应用程序托管的示例项目:https://github.com/mkArtakMSFT/Samples/tree/master/WpfAspNetCore
有些事要注意:
Microsoft.AspNetCore.Mvc
包的引用以添加对MVC的支持。