【问题标题】:How to Make HTML File Startup?如何使 HTML 文件启动?
【发布时间】:2014-02-28 21:44:34
【问题描述】:

我有 asp.net web api 项目。我已删除 views 文件夹并将 index.html 根级文件添加到解决方案中。
现在,当我访问页面http://localhost:59305/ 时,它显示HTTP Error 403.14 - 所以没有打开html 文件。

如何让文件先被打开?

【问题讨论】:

  • 我想知道你为什么要创建一个 Web API 项目并删除视图。
  • 创建单页应用程序。
  • 然后在 Visual Studio 中使用 Single Page Application 项目模板(肯定是 2013 年)
  • 我有 vs 2013,但没有 SPA。你是说 Service Pack 1 吗?
  • 它应该在那里,检查这个:asp.net/visual-studio/overview/2013/…

标签: c# asp.net-mvc-4 asp.net-web-api routing


【解决方案1】:

您必须配置路由引擎以忽略路由中的 HTML 文件。

在您的Global.asax.cs 中使用它:

RouteTable.Routes.IgnoreRoute("*.html");

同时尝试在您的 web.config 文件中设置默认文档。添加这个:

<system.webServer>
  <defaultDocument>
    <files>
      <clear />
      <add value="index.html" />
    </files>
  </defaultDocument>
</system.webServer>

【讨论】:

  • 还是一样。你是否正确理解了这个问题?我想将 index.html 显示为默认页面。
猜你喜欢
  • 1970-01-01
  • 2014-10-16
  • 2015-09-05
  • 1970-01-01
  • 1970-01-01
  • 2022-08-15
  • 1970-01-01
  • 2020-06-15
  • 2011-05-25
相关资源
最近更新 更多