0

I created customStyle.css file in wwwroot/css folder as below:

.custominput {
    border: 1px solid;
    border-radius: 1px;
    height: 30px;
    margin-bottom: 10px;
}

.mainPic {
    background-image: linear-gradient(rgba(255,255,255,0),rgba(255,255,255,0)),url("publicimage/mainbackgroundpic.png");
    background-repeat: no-repeat;
    height: auto;
    background-size: cover;
    background-position: center;
    background-attachment: fixed;}

Also I put required link in my layout.cshtml file like this:

 <link rel="stylesheet" href="~/css/customStyle.css" type="text/css" asp-append-version="true" />

but it doesn't work! Would you please help me?

Thanks in advance

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
R. Salehi
  • 183
  • 1
  • 3
  • 13
  • 1
    Have you tried checking the CSS file path? It might be pointing to the wrong place. – rawnewdlz Dec 17 '21 at 22:08
  • 1
    Does this answer your question? [css file not found - asp.net core web application](https://stackoverflow.com/questions/54854334/css-file-not-found-asp-net-core-web-application) – rawnewdlz Dec 17 '21 at 22:10
  • @rawnewdlz Thanks for your reply but before asked my question I checked that mentioned post. I checked every thing :( – R. Salehi Dec 17 '21 at 22:52
  • 1
    @Re Salehi can you post your layout page code shortly to understand your linkup? – Pritom Sarkar Dec 18 '21 at 18:25

1 Answers1

2

The styles or scripts inside wwwroot is governed by a special method inside Configure method in Startup.cs class.

That method is UseStaticFiles(). See below screenshot:

enter image description here

Arrange the methods exactly mentioned in the screenshot and then give it a try.

NOTE: I am using .NET Core v3.1 (Long time support). If you have lower version then please make sure you add your app.UseStaticFiles() before app.UseRouting() method.

Rohan Rao
  • 2,505
  • 3
  • 19
  • 39