我知道这里有一百万个类似/相同的问题(我知道是因为我已经阅读过它们),但我就是不知道为什么我的默认文档没有显示。它曾经; 如果我启用默认网站,则会显示该网站的默认页面。HTTP 错误代码是 404。
编辑:是因为我使用的是“localhost”还是顶级域?那是https://localhost/MyDefault.html有效,但我从https://localhost得到 404 。
我相信/猜测以下内容是问题所在。它曾经工作过:-
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<defaultDocument enabled="true">
<files>
<clear />
<add value="MyDefault.html" />
</files>
</defaultDocument>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
</system.webServer>
我一直在寻找 2 天然后遇到了我认为是解决方案的方法,但遗憾的是(听起来很合适)它不起作用:-(
仅供参考,这是一个 SPA/PWA,当我说 mvC 时,它实际上只是控制器。
这是 Global.asax 部分。
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
}
没有可用的 HOME 控制器。
这是返回的标准错误页面: - '/' 应用程序中的服务器错误。无法找到该资源。说明:HTTP 404。您要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。请查看以下 URL 并确保其拼写正确。
请求的网址:/
版本信息:Microsoft .NET Framework 版本:4.0.30319;ASP.NET 版本:4.8.3752.0
没有在 FRL 中创建文件
这是 404 错误: - 2019-12-04 03:55:34 ::1 GET / - 443 - ::1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+ (KHTML,+like+Gecko)+Chrome/78.0.3904.108+Safari/537.36 - 404 0 0 4
这是 FRT 请求摘要。完整的跟踪可以在 Complete FRT 中找到
[4]: