I maintain a moderate sized public internet website for a company built using C# and ASP.Net WebForms using the .NET Framework 3.5. One of our 3rd-party marketing/lead generation consultants wants to reserve several query string codes that go into Google Analytics for themselves and have those codes persist as the user moves around the website. Since (for obvious reasons) I don’t really want to have to touch every place we generate an internal URL link to maintain these codes, is there anywhere in the ASP.NET page lifecycle where I could intercept these (either when they are being written when the page is served or after the link is clicked) so I do not have to change the links generated on dozens of pages and hundreds of individual instances.
Thanks
If you’re on IIS 7, look into outbound rules using the IIS URL Rewrite module – http://learn.iis.net/page.aspx/657/creating-outbound-rules-for-url-rewrite-module/. They’re extremely powerful. You may be able to do this with older versions of IIS as well, but I’ve only worked with 7.
Adding the following rules to your web.config will cause all query string values in the request URL to be appended to the URLs in the hrefs of every anchor tag in the response. The rules will apply to every page in your site.