繁体   English   中英

如何在 Visual Studio 中定义 HTML 文件扩展名?

[英]How to define the HTML file extension in Visual Studio?

我的项目无法识别 css 和我创建的 html 文件中的其他文件,尽管我已经正确编写了扩展路径。 我该如何解决? 在此处输入图像描述

在此处输入图像描述

你没有把正确的路径放在那里。 您的“style.css”在“theme/src/style.css”中,而不是在“theme/style.css”中。 也使用 VS Code 而不是 Visual Studio,因为如果你只创建文件是没用的。 此外,您没有提供 JS 文件夹和 CSS 文件夹中的所有文件。

首先,您需要在Startup中配置服务 static 文件

app.UseStaticFiles(); //serves wwwroot by default

要为您的theme文件夹提供服务,您需要添加以下行

app.UseStaticFiles(new StaticFileOptions
{
    FileProvider = new PhysicalFileProvider(
        Path.Combine(Directory.GetCurrentDirectory(), "theme")),
    RequestPath = "/theme"
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM