以编程方式启动ASP.NET Core Web-API

问题描述 投票:2回答:3

如何从C#以编程方式启动ASP.NET Core Web-API?单击表单中的按钮后,API应该启动。

我已经通过Add -> Existing Project...将我的API添加到我的解决方案中,但我不知道如何从其他项目启动它。

Web-API在.NET Core 2.0上运行,我想从使用.NET Framework 4的项目启动它

c# asp.net asp.net-core-webapi
3个回答
1
投票

可能你正在寻找像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]


0
投票

您还可以尝试将该应用程序作为Windows Service运行,并在单击时启动该服务。


0
投票

这是一个展示WPF中ASP.NET Core应用程序托管的示例项目:https://github.com/mkArtakMSFT/Samples/tree/master/WpfAspNetCore

有些事要注意:

  • .NET Framework 4.6.1是可以托管ASP.NET Core应用程序的最低版本
  • 此示例是虚拟的,没有太多配置(基于空的ASP.NET Core Web应用程序模板内容)。但是,您可以添加对Microsoft.AspNetCore.Mvc包的引用以添加对MVC的支持。
© www.soinside.com 2019 - 2024. All rights reserved.