开发者

Shorter names for /ScriptResource.axd and/or /WebResource.axd in ASP.NET?

开发者 https://www.devze.com 2023-02-12 04:33 出处:网络
My page loads scripts and css from some custom assembly. For now, I use the ScriptManager to add scripts to the page (its CompositeScript) and the page\'s ClientScript.GetWebResourceUrl() for css file

My page loads scripts and css from some custom assembly. For now, I use the ScriptManager to add scripts to the page (its CompositeScript) and the page's ClientScript.GetWebResourceUrl() for css files. So, on the page(s) my scripts are referenced by /ScriptResource.axd and css are referenced by /WebResource.axd. Works fine except the fact that those URLs look really ugly. Is there any manageable way to replace those 开发者_运维问答urls with my own fake paths without moving/hosting script/css physical files somewhere? Any help or ideas would be greatly appreciated.


Use a Filter to find all the WebResource.axd and ScriptResource.axd src'es and replace them with something you like better. You then need a IHttpHandler, as Brian comments, that understands your new url-format and returns the same content as the original axd-files would have.

You should also look into combining all those script and css resources to save requests from the browser. How do I combine WebResource.axd and ScriptResource.axd files so as to result in less requests to my ASP.NET server?

0

精彩评论

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

关注公众号