You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

因Web API的web.config文件导致网站HTML文件无法访问的求助

问题修复方案

核心原因

当前web.config里的aspNetCore处理器设置了path="*",所有请求都会被ASP.NET Core接管,包括HTML、CSS这类静态文件。而你的Web API没有配置处理静态文件的路由规则,因此访问HTML时返回404错误。

修复步骤

将web.config中<handlers>节点下的path="*"修改为path="api/*",这样只有URL包含api/的请求会转交给Web API处理,静态文件请求则由IIS正常响应。

修改后的完整web.config代码:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="api/*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\LAV.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 4447276A-7814-4EFD-B2D8-457F7A8B94B4-->

额外检查项

如果修改后静态文件仍无法访问,可验证以下内容:

  • 确认httpdocs文件夹的权限设置,确保IIS_IUSRS用户拥有读取权限
  • 检查Plesk中网站的“HTTP handlers”设置,确认静态文件模块已启用(默认状态下为开启)

内容的提问来源于stack exchange,提问作者Astro

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 21:04:56