Deploying website with cookie-free domain path update for images and other resources
-
I'm working on as asp.net application. The application is reasonably large and involves lot of pages with many reference images and scripts. I have hosted such content on a cookie-free sub-domain. My problem is - I have to manually update the path for all images and scripts upon deployment, by making them absolute-references to cookie-free domain content from relative-references of actual domain. How do I automate this ? Has anybody done this ? StackOverflow also uses cookie-free domain for various images on the site. Here's example upvote image which loaded from http://sstatic.net/so/img/vote-arrow-up.png
-
Answer:
I solved a similar problem with custom controls (Images, etc.). Some I derived from existing controls (Image) some I created new. Within these Controls you could decide if you are in your dev environment or in production and render/change your links. EDIT: Add some example code. Note! This code is for demonstration purpose only! It's not perfekt! public class ExternalImage : System.Web.UI.WebControls.Image { protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (System.Configuration.ConfigurationManager.AppSettings["IsDev"] != "true") { this.ImageUrl = System.Configuration.ConfigurationManager.AppSettings["CookieFreeDomain"] + this.ImageUrl; } } }
this. __curious_geek at Stack Overflow Visit the source
Other answers
You can use tag transforms or control adapters. In case it helps, I cover both approaches in my book, along with code examples: http://rads.stackoverflow.com/amzn/click/1430223839
RickNZ
Related Q & A:
- How To Get Free Madden Roster Update For Free?Best solution by Yahoo! Answers
- How to get totaly free domain?Best solution by ehow.com
- Where I can I find a reliable free domain name?Best solution by Yahoo! Answers
- Free Domain Server?Best solution by mydomain.com
- How can I get a free domain?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.