skip to Main Content

I’m just learning ASP.NET and I created the default Web App template in Visual Studio. There are some bootstrap.css files under wwwroot folder but even if I comment everything out it doesn’t have any effect on how the website looks like.

For example in _Layout.cshtml the @RenderBody method is wrapped up in div class="container" but editing ".container" in the CSS files doesn’t do anything. It’s only when I delete the class name "container" in the div element something actually happens. So why editing these CSS files don’t have any effect?

2

Answers


  1. The browser is likely caching bootstrap.css because it is linked into the page. Try opening dev tools in your browser and telling it to dump the cache and hard reload (if you are using chrome/edge, for example).

    Some devs get around this by only opening their site in private mode or with debug/dev flags. FireFox even makes a developer edition of their browser too.

    I think running your site using "dotnet watch" might also fix the issue.

    Login or Signup to reply.
  2. Check your layout, what .css file you used. You can see it in the layout or using F12 to see it in the network.

    Below is two options:

    1.If you used the bootstrap.min.css in your layout

     <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    

    You need comment .container in your bootstrap.min.css

    2.If you used bootstrap.css in your layout

     <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
    

    You need comment .container in your bootstrap.css

    The structure is like below:

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search