Using the "Request" .Net Framework class ( System.Web.HttpRequest )
should be a little faster and more efficient than using Request.ServerVariables.
RequestUrl.aspx:
-------------------------
<%@ Page Language="VB" %>
<script language="VB" runat="server">
Sub Page_Load(ByVal obj As Object, ByVal e As EventArgs)
Dim url1 As String = Request.Url.ToString
Label1.Text = url1
End Sub
</script>
<head>
<title>Retrieve Full URL</title>
</head>
<html>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" Runat="server" Text="Label" Width="238px" Height="19px"></asp:Label><br />
</div>
</form>
</body>
</html>
-----------
If you only need the Application's virtual path, use :
Request.ApplicationPath.ToString
If you only need the full virtual path, use :
Request.RawUrl.ToString
Juan T. Llibre
ASP.NET MVP
===========
MWells said:
"URL" will give you the full path, not including hostname. I believe there
is also a "RAW_URL" or "URL_RAW" that gives you the full path.
Hello
I need to find out full URL of my application name, I tried using
Request.ServerVariables["SERVER_NAME"] but it returns only serverername,
and I need virtual directory name as well.
Thnx in advance