好吧,所以我不知道我在這裏失蹤。我想要做的是顯示我的靜態css文件鏈接到我的索引頁面。我已經加載了依賴關係,並將它放在startup.cs中,希望有人能告訴我在哪裏搞亂了它。 ALl這個應該做的就是在索引中將h1轉換爲綠色。頁面的加載恰好不會改變顏色。靜態文件不通過wwwroot c加載#
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
你有沒有研究通過IIS設置中啓用靜態內容? –
是啊我在學校學習所有這一切,並遵循所有的東西,甚至resarched微軟我似乎有它設置正確的思想我得到了一些愚蠢的破 –
你可以瀏覽到/css/style.css? –