【问题标题】:Getting 404 for CSS and JS assets in Kestrel while debugging in Visual Studio Code在 Visual Studio Code 中调试时,在 Kestrel 中为 CSS 和 JS 资产获取 404
【发布时间】:2016-10-04 19:40:35
【问题描述】:

在 Ubuntu 16.04.1 LTS 和 Visual Studio Code 1.5.3 上玩弄 ASP.NET Core 时,我遇到了这个问题。这是我所做的:

  1. 创建空文件夹并在那里生成一个新的 dotnet Web 应用程序(dotnet new -t Webdotnet restoredotnet build)。
  2. 从终端运行应用程序并访问http://localhost:5000/ 并观察默认站点如何按预期工作。
  3. 在 Visual Studio Code 中打开同一目录,接受安装调试所需的资产。
  4. 开始调试,Firefox 将打开一个带有http://localhost:5000/ 的选项卡
  5. 请注意,网站部分加载,元素错位和倾斜。启动检查工具后,所有 JS 和 CSS 请求都会收到 404。

启动似乎有静态文件服务命令:

    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseStartup<Startup>()
            .Build();

        host.Run();
    }

另外,Startup 类的方法包含对UseStaticFiles() 的调用。

我还上传了a video of the steps here。该项目的code is here

【问题讨论】:

    标签: debugging ide http-status-code-404 visual-studio-code static-files


    【解决方案1】:

    看来我得跑了

    sudo bower install --allow-root
    

    为了在本地安装这些资产。至于能够运行bower,您需要安装 npm 和 git(通常它们是),同意 xcodebuild 许可证(在 OS X 上)和其他小东西。

    【讨论】:

      猜你喜欢
      • 2014-09-27
      • 1970-01-01
      • 2023-01-29
      • 2017-12-01
      • 2015-07-11
      • 1970-01-01
      • 2020-07-23
      • 2022-12-17
      • 1970-01-01
      相关资源
      最近更新 更多