Menu

Move your MVC 5 bundles to ASP.NET Core without changing a single URL
📰

Move your MVC 5 bundles to ASP.NET Core without changing a single URL

DEV Community: dotnet·cadamsmith·about 8 hours ago
#g1QkrdJX
#devtodotnet#devto#dev#jquery#bundles
Long article (820 words) — no AI summary yet.
Reading 0:00
15s threshold

If you maintain an ASP.NET MVC 5 app, its CSS and JavaScript probably go through System.Web.Optimization :

bundles . Add ( new ScriptBundle ( "~/bundles/jquery" ) . Include ( "~/Scripts/jquery-{version}.js" ) ) ; bundles . Add ( new StyleBundle ( "~/Content/css" ) . Include ( "~/Content/bootstrap.css" , "~/Content/site.css" ) ) ;

Enter fullscreen mode

Exit fullscreen mode

@Styles.Render("~/Content/css") @Scripts.Render("~/bundles/jquery")

Enter fullscreen mode

Exit fullscreen mode

That package has two problems today.

It doesn't exist on ASP.NET Core. Moving the app means replacing every bundle, usually with a build step or a different runtime bundler, and the bundle URLs ( /bundles/jquery , /Content/css ) change on the way. Anything that requested them, from cached pages to other sites to monitoring, breaks.

It still minifies with WebGrease. WebGrease is long abandoned and fails on modern syntax.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.