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

4
  • 1
    Have you tried checking the CSS file path? It might be pointing to the wrong place. Commented Dec 17, 2021 at 22:08
  • 1
    Does this answer your question? css file not found - asp.net core web application Commented Dec 17, 2021 at 22:10
  • @rawnewdlz Thanks for your reply but before asked my question I checked that mentioned post. I checked every thing :( Commented Dec 17, 2021 at 22:52
  • 1
    @Re Salehi can you post your layout page code shortly to understand your linkup? Commented Dec 18, 2021 at 18:25

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.