好的,所以我不知道我在这里失踪了什么。我要做的就是显示我的静态css文件链接到我的索引页面。我已经加载了依赖项并将它放在startup.cs中,希望有人可以告诉我在哪里弄乱它。这应该做的是将索引为绿色的h1转换页面加载得很好,只是不改变颜色。
Project.json
"dependencies": {
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
Startup.cs
public void Configure(IApplicationBuilder app, ILoggerFactory
loggerFactory)
{
// Use the Mvc to handle Http requests and responses
loggerFactory.AddConsole();
app.UseStaticFiles();
app.UseDeveloperExceptionPage();
app.UseMvc();
}
Index.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Index</title>
<link rel="stylesheet" href="~/css/style.css"/>
</head>
<body>
<div id = "test">
<h1>Hello ASP.NET Mvc!</h1>
</div>
</body>
</html>
Style.css
*{
margin: 0px;
padding: 0px;
}
h1{
color: green;
}
Structure of wwwroot
wwwroot
css
style.css