简体   繁体   中英

vb.net CDN Images Only on Production

Whats the right way to change the url for all the images on my site to use a cdn url or not based on a web.config value.

I have this web.config value

<add key="UseCDN" value="1"/>

now my page has a whole bunch of <\\asp:image imageurl="RELATIVEPATH" tags.

I want them to point to my machine when "useCDN" = 0 and to cdn.com\\RELATIVEPATH when "useCDN" = 1

whats the best way to do this?

For you to implement a cross cutting solution, you have to extend the image control class and override the Render method to use the use the CDN value (if in production).

Or just create a normal ASCX user control and use it. Can't search now but a simple search will get you plenty of tutorials.

UPDATE:

A tutorial to help you do it

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM