【问题标题】:ASP.NET End point 404 on IIS ServerIIS 服务器上的 ASP.NET 端点 404
【发布时间】:2020-07-27 10:39:48
【问题描述】:

一直在使用 Visual Studio 2019 和 ASP.Net。在开发过程中让我所有的端点工作。在 IIS 上部署时,我的所有端点都返回 404。查看日志时,我收到“404 0 2”错误。 我可以很好地浏览所有页面,只是端点不起作用。我尝试在我的 Web.Config 中添加各种东西,结果都一样。

是具有最新版本 IIS 的 2019 服务器。 任何帮助表示赞赏。猜测 IIS 上的设置有误?

端点使用控制器完成,示例代码如下:

        [Route("~/api/students/getyear/{yearid}")]
        public async Task<ActionResult<IEnumerable<Student>>> GetYear(int yearid)
        {
            return await _context.Student.Where(x => x.yearid == yearid).ToListAsync();
        }

使用调用

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

在调试它时,我可以从“https://localhost:5001/api/students/getyear/0”访问它,而在使用“intranet.domain.co.uk/studentnotices/api/students/getyear/0”尝试我的 IIS 时,我收到 404 错误

我将代码发布到发布文件夹并将其复制到我的 IIS。也尝试过直接发布到 IIS 但结果相同

【问题讨论】:

  • 所以你得到一个 404 命中一些神秘的“端点”。这些端点是什么?他们是控制者吗? Web 表单页面?设置它们涉及什么配置?您需要在描述上下文的问题中添加更多细节。
  • 已编辑。希望越来越好

标签: asp.net iis http-status-code-404


【解决方案1】:

win32-status已经提示“系统找不到指定的文件。”

所以我认为您的 IIS 正在尝试从物理路径执行 URL。 这可能是因为您的静态文件处理程序正在接管请求,而不是 asp.net 无扩展处理程序。

请依次安装 IIS asp.net 扩展功能打开或关闭 Windows 功能。对于 .net core 应用程序,请确保已安装 asp.net core web hosting bundle。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-19
    • 2014-12-21
    • 2014-11-17
    • 2018-06-30
    • 1970-01-01
    相关资源
    最近更新 更多