Visual Studio 2017 (v15.4.4)
ASP.NET Core MVC
I created new ASP.NET Core Web Application from the empty template and filled it. But when I start debugging I see that my CSS-file is not accessible.
The page for the web address was not found http://localhost:51308/css/styles.css
HTTP ERROR 404
Why does it happen and how can I solve this problem?
styles.css:
.field-validation-error {color: #f00;}
.field-validation-valid {display: none;}
.input-validation-error {border: 1px solid #f00; background-color: #fee;}
.validation-summary-errors {font-weight: bold; color: #f00;}
.validation-summary-valid {display: none;}
RsvpForm.cshtml:
@model Razor.Models.GuestResponse
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Razor
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>RSVP Form</title>
<link rel="stylesheet" href="~/css/styles.css"/>
</head>
<body>
<div>
This is RSVP form.
<form asp-action="RsvpForm" method="post">
<div asp-validation-summary="All"></div>
<p>
<label asp-for="Name">Your name:</label>
<input asp-for="Name" />
</p>
<p>
<label asp-for="Email">Your email:</label>
<input asp-for="Email" />
</p>
<p>
<label asp-for="Phone">Your phone:</label>
<input asp-for="Phone" />
</p>
<p>
<label>Will you attend?</label>
<select asp-for="WillAttend">
<option value="">Choose an option</option>
<option value="true">Yes I'll be there</option>
<option value="false">No, I can't come</option>
</select>
</p>
<button type="submit">Submit RSVP</button>
</form>
</div>
</body>
</html>
UPD
I renamed styles.css to site.css and shared this example on GitHub: here is the code source of this example.
