如何将 ASP.NET Core Web 应用程序部署到 Windows Server 2016 上的 IIS

2024-03-07

1.我想做的事

I am new to C# and now trying to deploy a "ASP.NET web application" to IIS. I tried to follow the steps introduced in this website but instead of the view (Index.cshtml) showing, some directory list shows up when I test “Browse” from IIS.
https://www.guru99.com/deploying-website-iis.html

2.当前问题

It is currently showing some directory list instead of the view (Index.cshtml).

显示目录列表 https://i.stack.imgur.com/we7mH.jpg



3.我做了什么

STEP1.创建ASP.NET Core应用程序

-添加项目后,我添加了一个控制器(HomeController)和一个视图(Index.cshtml)
- 之后我可以使用 IIS Express 进行访问,URL 为“https://localhost:44320/Home/Index”

STEP1.创建ASP.NET Core应用程序 https://i.stack.imgur.com/Nhd2D.jpg

STEP1.成功 https://localhost:44320/Home/Index https://i.stack.imgur.com/Q2cck.jpg


STEP2.发布
-给出目标文件夹并生成应用程序
-目的地我在“C\TempApp”中给出了路径(抱歉,图像中的路径是错误的,我实际上给出了“C\TempApp”)

STEP2.发布 https://i.stack.imgur.com/4yVJa.jpg

STEP3.在IIS中添加新的应用程序
-给出 Pysycal 路径“ C:\TempWeb\Home\View ”
- 将主机指定为“localhost”

STEP3.在IIS中添加新的应用程序 https://i.stack.imgur.com/Hg0Sj.jpg

STEP4.测试
- 右键单击​​新应用程序 -> 管理应用程序 -> 浏览

STEP4.测试 https://i.stack.imgur.com/Y357c.jpg

STEP5.修复错误
根据 403 屏幕中显示的消息,我启用“目录浏览”,然后得到以下结果。

STEP5.修复错误 https://i.stack.imgur.com/we7mH.jpg

2021/1/27 19:00 添加

I got advice to check the default page, and it seems the Default page was auto generated to point the View I created.

当我检查IIS的“服务器角色”设置时,发现ASP.NET和.NET 4.7没有被选中,估计可能是这个原因。

IIS 服务器角色设置 https://i.stack.imgur.com/E2J8g.jpg


要在 iis 中运行 asp.net core 站点,您必须安装 .net core 托管捆绑包和运行时。

您可以根据您的版本从以下链接下载:

https://dotnet.microsoft.com/download/dotnet-core/3.1 https://dotnet.microsoft.com/download/dotnet-core/3.1

为asp.net core站点发布文件夹分配iis_iusrs和iusr权限。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何将 ASP.NET Core Web 应用程序部署到 Windows Server 2016 上的 IIS 的相关文章

随机推荐