开发者

Populate javascript template at startup global.asax

开发者 https://www.devze.com 2022-12-25 08:18 出处:网络
I use asp.net mvc & going to build javascript files at application startup depending on site configuration.

I use asp.net mvc & going to build javascript files at application startup depending on site configuration.

I am going to have some javascript file templates that will be populated with appropriate constants and put into /scripts folder.

Please, suggest me the best way to do that. I want t开发者_如何学JAVAo have something like:

application_startup() { string populatedFile = Html.RenderPartial("/scripts/script.template.js"); write populatedFile into /scripts folder... }

Thank you in advance !


I'd look at putting the logic in ASHX handler rather than Global.asax, then reference the ASHX as a script reference in your Site Master.

With regards to the actual logic. I'd be pulling your templates using a reader and creating the final script with a String Builder.

If the configuration is not going to change that much, make sure you are caching your output.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号