【发布时间】:2020-04-07 16:21:09
【问题描述】:
我在 Mac 上使用 Visual Studio Code 开发了一个带有 .Net Core 3 的 Web API,没有问题。
我用命令发布:
dotnet publish -c release
但我无法在 IIS 上部署: 发布命令不会生成任何“web.config”文件,所以我使用我在网上找到的这个配置(可能是针对 Core 2.0 的?):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet"
arguments=".\thenameofmydll.dll"
stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout"
hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
我的“program.cs”:
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
我的问题:
“program.cs”是否可以与 IIS 一起使用?
“web.config”是否正确?
我在网上找到了几个示例,但所有这些都是部分或不完整的......如果我要求以前问过的东西,很抱歉,但我找不到 .Net Core 3 的完整示例
谢谢!
【问题讨论】:
-
无法重现您所说的内容。
web.config即使在 macOS 上也会生成。
标签: c# macos iis .net-core webapi