Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting Hashed Webpack Bundles Working in ASP.NET Framework

Tags:

c#

.net

angular

In .NET Core, referred webpack bundles using asp-src-include. obviously main.js something like main.{hash}.js.

  <script type="text/javascript" asp-src-include="~/main*.js"></script>

Worked fine in .NET Core. But in .Net framework 4.5, obviously I can't able to useasp-src-include. So how to overcome this. src attribute not working like asp-src-include

 <script type="text/javascript" src="~/main*.js")"></script> //this is not working
like image 658
Arun Kumar Avatar asked Sep 05 '25 19:09

Arun Kumar


1 Answers

You can try some thing like this in the BundleConfig.cs

bundles.Add(new ScriptBundle("~/bundles/AngularMain").IncludeDirectory(
                 "~/Scripts/dist/","main.*"))

Refer them in you layout

@Scripts.Render("~/bundles/AngularMain")

you can find more info in this link Bundling and Minification I hope this might help

like image 141
raghava patnam Avatar answered Sep 08 '25 10:09

raghava patnam