我一直在 Visual Studio 中开发 ASP.NET Web 应用程序项目。在该项目中,当用户输入主机名时,他们会收到 404 错误,但我希望他们在刚刚输入主机名时被重定向到 index.html。
下面是我尝试使用但没有用的代码。它说有太多的重定向,我认为这与路径值为空有关
<location path="">
<system.webServer>
<httpRedirect enabled="true" destination="index.html" httpResponseStatus="Permanent" />
</system.webServer>
</location>
有没有人有建议?
如果您使用 MVC,您可以创建一个默认路由,但由于您要求在 web.config 中执行此操作,请尝试:
<configuration>
<system.web>
<customErrors defaultRedirect="index.html" mode="On">
<error statusCode="404" redirect="index.html"/>
</customErrors>
</system.web>
</configuration>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句