I have been trying to implement bundling and minification for my existing asp.net webforms project and unfortunately it is ending up with 404 responses.
Let me first share the steps I have followed.
Installed System.Web.Optimization
through nuget.
Added BundleConfig
class and registered it on Glabal.asax Application_Start event
My code to bundle the JS files.
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/modelJs").Include(
"~/src/model.js",
"~/src/calender.js",
"~/src/common.js",
"~/src/insurance.js"));
...
<asp:PlaceHolder runat="server"> <%: System.Web.Optimization.Scripts.Render("~/bundles/modelJs") %> </asp:PlaceHolder>
http://localhost:9011/bundles/modelJs/?v=xNmmFhbzC1isUARLQne-XoBRkWBWApbnRQX8AGvNxQY1
I have also checked the sample project which gets added in VS2013 webforms application and surprisingly, it seems to be working fine.
I have seen many questions with similar problems on SO but was not able to solve it.
Well, the solution turns out to be very simple. Just added '/' after bundling folder which is modeljs
in this case.
bundles.Add(new ScriptBundle("~/bundles/modelJs/").Include(
Unfortunately, I didn't find this in any available source codes so I ended up wasting a lot of time. :-/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.