摘要

最近项目中,尝试使用asp.net core开发,在部署的时候,考虑现有硬件,只能部署在windows上,linux服务器暂时没有。

部署注意事项

代码中启用iis和Kestrel

 public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
            
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
            .UseKestrel()           
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .UseApplicationInsights()
            .Build();

    }

在服务端安装

 .NET Core Windows Server 托管捆绑包

Microsoft Visual C++ 2015 Redistributable,再安装 .NET Core Windows Server 托管捆绑包。

 

重新启动 IIS 将选取安装程序对系统 PATH 所作的更改。

发布

使用vs发布或者使用命令,这里由于使用vs2017开发,就直接用vs发布了

在服务端新建站点

Asp.net core使用IIS在windows上进行托管

修改应用池CLR为No Managed Code

Asp.net core使用IIS在windows上进行托管

可以下面新建子站点test

Asp.net core使用IIS在windows上进行托管

确认进程模型标识拥有适当的权限。

例如,应用池需要对文件夹的读取和写入权限,以便应用在其中读取和写入文件。

 常见错误

如果通过ip和端口访问,报500错误,但在服务器上 通过dotnet \xxxxx.dll可以启动kestrel,并可以通过http:\\localhost:5000进行访问,一般可以通过修改站点目录权限进行解决。至少可以读写的权限。

Asp.net core使用IIS在windows上进行托管

其他错误,可以参考

https://docs.microsoft.com/zh-cn/aspnet/core/host-and-deploy/iis/troubleshoot

相关文章:

  • 2021-08-17
  • 2021-10-29
  • 2021-09-27
  • 2023-03-21
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2018-06-18
  • 2022-12-23
  • 2022-12-23
  • 2021-01-18
  • 2022-12-23
相关资源
相似解决方案