【问题标题】:ASP.NET Web API index.html does not load; Server Error in '/' Application, The resource cannot be foundASP.NET Web API index.html 不加载; “/”应用程序中的服务器错误,找不到资源
【发布时间】:2014-01-16 20:21:29
【问题描述】:

我正在关注这个tutorial

当我构建解决方案时,index.html 页面不会显示并且我收到此错误:“/”应用程序中的服务器错误。 我不确定如何启用详细的错误报告。

这是我的 Web.config 页面:

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->

<configuration>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
  </appSettings>

  <system.web>

    <httpRuntime targetFramework="4.5" />

    <compilation debug="true" targetFramework="4.5" />
    <customErrors mode="Off"/>
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>

  </system.web>

  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

  <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
</configuration>

IIS Express 显示为http://localhost:11527/

【问题讨论】:

  • 您是否查看了项目参考页面以查看是否可以找到所有参考?
  • 我的项目参考页是空的。我认为本教程没有任何参考资料。
  • 我认为您需要命名空间中列出的引用,例如:i.imgur.com/SGB3rrK.png(它会解释缺少的资源消息)。

标签: c# asp.net iis asp.net-web-api


【解决方案1】:

您确定您是像http://localhost:11527/index.html 一样访问它吗?请注意,这是使用 Empty 项目模板创建的,因此没有 MVC,因此您不能期望显示默认视图,因此您需要在 url 中明确提及 index.html

【讨论】:

  • 我添加了app.UseMvc(),但默认没有加载index.html,如何在Startup.cs文件中做到这一点?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-15
  • 2022-07-28
  • 2019-06-21
  • 2015-01-21
相关资源
最近更新 更多