Setting a hyperlink programmatically in a master page without url basing
<p>I'm trying to set a NavigateUrl property on an asp:hyperlink that's found inside a nested master page. I have the following:</p>

<pre><code>link_previous.NavigateUrl = HttpUtility.UrlEncode(Request.UrlReferrer.ToString());
</code></pre>

<p>It's used to fill in the url of the previous page from the referrer. So, the url is not necessarily from inside of the site. </p>

<p>(As an aside, I'm not a fan of this kind of functionality as it mimics the back button of the browser, but it's not my call).</p>

<p>This gives me <code>http://localhost/templates/&lt;full url of referring page&gt;</code>, which I clearly don't want. The master page is in the /templates folder.</p>

<p>I could call Page.ResolveUrl on this, but then I won't be able to UrlEncode the value. This is necessary as it can open up a XSS attack vector.</p>

<p>How can I otherwise prevent .net from basing the url from the location of the master page while maintaining the ability to url encode?</p>

<p><strong>Edit</strong></p>

<p>I could build up the url markup manually and insert it into a literal control, but it's a multilingual site, so that would get a bit ugly.</p>
