Q:

Adding new query parameter to hyperlinks dynamically

I have several hyperlinks in my homepage. I would like to add a query parameter at the end of each hyperlink dynamically.
For example;
<a href="detail.aspx?id=2" target="_blank" >xyz</a>
<a href="detail.aspx?cid=5" target="_blank" >pqr</a>

will be converted to
<a href="detail.aspx?id=2&redirectFrom=hp" target="_blank" >xyz</a>
<a href="detail.aspx?cid=5&redirectFrom=hp" target="_blank" >pqr</a>

a new query parameter "redirectFrom" with value have been added to the converted hyperlinks.
How I can achieve it using ASP.net C#?

A:

Maybe you can use Request.UrlReferrer.AbsolutePath instead of dynamically modifying each Link in your page. Please make sure whether or not UrlReferrer is null or not with every Request.
Good luck!

