Why does ASP.Net rewrite relative paths in runat=server anchor controls?

Posted by Atomiton on Stack Overflow See other posts from Stack Overflow or by Atomiton
Published on 2010-03-24T15:20:57Z Indexed on 2010/03/24 15:23 UTC
Read the original article Hit count: 353

Filed under:
|
|
|

I have UserControls in a Controls folder in my solution:

/Controls/TheControl.ascx

If specify the following:

<a runat="server" href="./?pg=1">link text</a>

ASP.Net seems to want to rewrite the path to point to the absolute location. For example, If the control is on site.com/products/fish/cans.aspx the link href will be rewritten to read

<a href="../../Controls/?pg=1

Why does Asp.Net rewrite these control paths, and is there an elegant way to fix it?

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about relative-path