CSS Changes on MVC App Not Working

CSS changes on MVC App not working

This is likely due to the bundling framework using bootstrap.css in local/debug mode and bootstrap.min.css when you deploy. The framework uses a set of conventions when determining which files to add to a bundle, one of which is to use the .min version of a file, if it exists, for release builds. This is probably what's biting you. You made the change in bootstrap.css but not in bootstrap.min.css.

Try deleting bootstrap.min.css and re-deploying. This should force the frameworkt to minify and use the bootstrap.css file that you modified.

CSS not updated during debugging ASP.NET MVC application

Your browser is caching the css. If you force a refresh with F5 that should display any changes.

CSS is not being applied after changes

Hit the Ctrl-F5 for reloading the page without using the cached contents

.NET Core MVC Page Not Refreshing After Changes

There was a change made in ASP.NET Core 2.2 it seems (and I can't find any announcements about this change). If you are not explicitly running in the 'Development' environment then the Razor Views are compiled and you will not see any changes made to the .cshtml

You can however turn off this using some config in your Startup class as follows.

services.AddMvc().AddRazorOptions(options => options.AllowRecompilingViewsOnFileChange = true);

For ASP.NET Core 3.0 and higher, see Alexander Christov's answer.

CSS isn't working with ASP MVC project

The reason for the 404 response could be because you have the css file within a subdirectory of Views.

By default, all files within the Views folder aren't served due to the web.config in the Views folder containing this setting under <system.web>:

<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

You could change the above setting but I would recommend moving your sass and css out into a higher level directory.

More here: Haacked article



Related Topics



Leave a reply



Submit