ASP.NET relative path ASP.NET relative path asp.net asp.net

ASP.NET relative path


Because you're using it directly in markup, rather than in a server control. Something as simple as this should fix it:

<a runat="server" href="~/Account/Login.aspx">Login</a>

Basically, the ~ path reference needs to be translated on the server, since it's a reference to the server path of the application's base directory. Plain HTML markup isn't processed on the server, it's just delivered as-is to the client. Only server-processed code will translate the ~ path to what it resolves to.


use this command

<a href="<%=Page.ResolveUrl("~/product.aspx")%>" >Link To Products</a>


You can use ~ when refering to URLs inside ASP.NET Server Controls.You are using it in a <a> tag which is just plain html that doeesn't know anything about ~ . use '"/Images/SampleImage.jpg"' instead