英文:
Preview ASP.NET Core Website Changes with IIS Application
问题
我正在尝试使用ASP.NET Core来开展一个个人项目,并利用IIS,这样我就可以简单地刷新页面并查看更改生效并进行微调。
在线的每个指南似乎都是关于发布页面的,似乎没有涵盖开发过程。我掌握了使用IIS的基本知识,但似乎无法弄清楚要选择哪个目录作为物理路径,或者如何让cshtml页面在浏览器中加载。
有人能帮忙吗?
尝试过:
- 将默认网站的物理路径设置为解决方案的根目录
- 将默认网站设置为Views/Home目录
- 添加一个应用程序,其物理路径设置为解决方案的根目录
- 将.NET CLR版本设置为“无托管代码”
期望本地主机页面显示index.cshtml页面,但实际上我收到了以下错误:
*HTTP错误404.17 - 未找到
所请求的内容似乎是脚本,将不会由静态文件处理程序提供。
最可能的原因:
请求匹配了通配符mime映射。该请求映射到静态文件处理程序。如果存在不同的先决条件,则请求将映射到不同的处理程序。*
如果有人能给我一个关于如何做到这一点的链接,那将是很棒的,我认为不需要配置发布设置来实现这一点,但我可能错了。
编辑:应该指出我在使用Windows 10专业版上使用IIS。
英文:
I'm trying to work on a personal project using ASP.NET Core and utilize IIS so I can simply refresh the page and see the changes take effect and make minor adjustments.
Every guide online seems to be about publishing the page and doesn't seem to cover the development process. I have the basics of using IIS but can't seem to figure out what directory to target select for the physical path, or how to get the cshtml pages to load in browser.
Can anyone help?
Tried:
- Setting Default Web Site's physical path to the root of the solution
- Setting Default Web Site to the Views/Home directory
- Adding an Application with the physical path set to the root of the solution
- Setting .NET CLR version to "No Managed Code"
Was expecting the localhost page to display the index.cshtml page, however instead I get the following error:
*HTTP Error 404.17 - Not Found
The requested content appears to be script and will not be served by the static file handler.
Most likely causes:
The request matched a wildcard mime map. The request is mapped to the static file handler. If there were different pre-conditions, the request will map to a different handler.*
If someone could give me a link to how you do this that would be great, I don't think that the publish settings need to be configured to do this but I could be wrong.
Edit: Should specify I'm using IIS on Windows 10 Professional.
答案1
得分: 0
HTTP错误 404.17 - 未找到
请求的内容似乎是脚本,将不会由静态文件处理程序提供服务。
对于这个错误,请尝试在“添加/删除程序”下安装丢失的.NET组件,然后重新启动服务器。
这个链接可能会对您有帮助:HTTP错误404.17未找到
如果问题无法解决,我建议您使用失败请求跟踪来查看详细的错误消息。failedReqLog将提供关键的错误和警告,这将帮助您识别问题。
此链接提供了启用失败请求跟踪以捕获详细错误的方法:使用IIS 7中的跟踪来排查失败的请求问题
英文:
> HTTP Error 404.17 - Not Found
>
> The requested content appears to be script and will not be served by the static file handler.
For this error, please try installing the missing .net stuff under the the Add/Remove Programs, then reboot the server.
This link may help you: HTTP Error 404 17 Not Found
If it can't be resolved, I suggest you use the failed request trace to see the detailed error message. The failedReqLog will provide the key error and warning, which will help you to identify the problem.
This link provide the method to enable failed request tracing to capture the detailed error: Troubleshooting Failed Requests Using Tracing in IIS 7
答案2
得分: 0
"Adding an Application with the physical path set to the root of the solution" 是导致后续所有错误的错误步骤。如果您想在IIS上获得ASP.NET Core的开发支持,唯一的选择是使用Visual Studio,了解更多信息。 – Lex Li
英文:
Lex Li provided the information required to properly set up the live previewing in a comment on the question:
"Adding an Application with the physical path set to the root of the solution" is the wrong step that leads to all following errors. If you want development support for ASP.NET Core on IIS, you only option is to use Visual Studio, learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/…"
– Lex Li
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论