Trigger the bundle inclusion from partial or editor templates in ASP.NET MVC 4

♀尐吖头ヾ 提交于 2019-12-04 16:04:50

This is something we are tracking in our backlog, its a fairly complex feature so we probably won't get to this for a few versions.

Our early thoughts are basically:

  • Allow registration of named assets, i.e. Assets.Register("jquery").Include("~/scripts/jquery.js")
  • Allow inclusion of assets by name in bundles
  • Add something like Scripts.Requres("jquery") which is similar to your TriggerInclusion, which basically registers the jquery asset on the page.
  • Something like Scripts.RenderRegistered() would render out all of the registered scripts on your page, in a location of your choosing, and also do deduplication of assets, etc.

We aren't sure how high to prioritize this feature, so if this is something that you really want, I created an issue on the codeplex site here, vote for it.

I rolled my own. It was easy to build and works well for me.

https://github.com/ronnieoverby/MvcAssetManager/blob/master/MvcAssetManager/Infrastructure/AssetManager.cs

There's likely some bugs, I haven't used it so much because most of my projects are still MVC3. But what little I have used it, it's done the trick.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!