Redirect a page using a Header
So where does the Redirect fit in?
Affiliate sites merely send clicks through to merchants via an affiliate network, that tracks the referral and the conversion. But to capture the information required for Google's Analytics you need to stick a page in between the viewed page and the referral to execute the Google Analytics snippet.
This is relatively simple and can be achieved a number of ways, but the best method I have discovered is to use the code below. In the Page_Load you simply append a Header to Refresh the page, set the time in seconds before the Refresh occurs and supply the URL.
Response.AppendHeader("Refresh", "0; URL=" + Affiliate.TrackingURL);
You won't find this in the source of the page as it's passed in the HTTP response headers to the browser.
Other implementations of this solution?
If you have a web application that requires a user to login, you can use this in conjunction with Session.Timeout to logout a user after a period of in activity between pages in the application.
I hope you find uses for this in your next ASP.Net application.
A self confessed Microsoft bigot, Paul loves all Microsoft products with a particular fondness for SQL Server. Paul is currently focusing on Web 2.0 patterns and practices and is always looking for better ways of doing things.
I love the .net platform, and I find it to be the most productive toolset I have used to date.