tags:

views:

40

answers:

1

When user requests http://localhost/WebApp1/Default.aspx, txtApplicationPath.Text should be assigned “/WebApp1”, while txtAbsolutePath.Text should be assigned “http://localhost/WebApp1/Default.aspx”, but instead both textboxes display empty strings.

Why?

Default.aspx:

<asp:TextBox ID="txtApplicationPath" runat="server" 
    Text='<%# HttpContext.Current.Request.ApplicationPath %>'>
</asp:TextBox> <br />
<asp:TextBox ID="txtAbsolutePath" runat="server" 
    Text='<%# HttpContext.Current.Request.Url.AbsolutePath %>'>
</asp:TextBox> 

thank you

+1  A: 

if you want the full url you should use Request.Url.OriginalString, because AbsolutePath will omit the host part of the url.

user468524