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