简体   繁体   中英

Not able to find css stylesheets or images - ASP.NET

I'm new to web development but have some experience with C#, so I'm trying my luck with ASP.NET. I was able to create the base app and so on, however now I want to use my own CSS stylesheet.

I tried using the exact syntax that the base app uses:

<head runat="server">
        <meta charset="utf-8" />
         <meta name="viewport" content="width=device-width, initial-scale=1.0" />
         <title>@ViewData["Title"] - SmtteProject</title>

         <environment include="Development">
             <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
         </environment>
         <environment exclude="Development">
             <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
                   asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
                   asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute"
                   crossorigin="anonymous"
                   integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"/>

         </environment>
         <link rel="stylesheet" href="~/css/test.css"/>
         <link rel="stylesheet" href="~/css/site.css" />
     </head>

Where the test.css is the stylesheet I want to use. It is in the exact same directory as site.css, however I get this error in the console on the page:

GET http://localhost:5000/css/test.css net::ERR_ABORTED 404 (Not Found)

I tried using runat="server" in both the head and in the link, as I saw quite a few answers online with this solution. However, that did not do the trick either.

I tried displaying an image that was in an images directory in the exact same way, but encountered the same issue.

Any help welcome.

It's C ascading S tyle S heets, or CSS . Not CCS . I think that this naming confusion is the root of your problem.

Your file is named test.ccs . It should be named test.css , per the HTML snippet you provided.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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