get full URL?

  • Thread starter Thread starter MattB
  • Start date Start date
M

MattB

Is there something in the .Net libraries that will let me retrieve (or
get enough information to recreate) the full URL of a page in my
application? Sort of like the reverse Server.MapPath() that would at
least give me back the "http://www.mydomain.com" part of the url?
Thanks!

Matt
 
MattB said:
Is there something in the .Net libraries that will let me retrieve (or
get enough information to recreate) the full URL of a page in my
application? Sort of like the reverse Server.MapPath() that would at
least give me back the "http://www.mydomain.com" part of the url?
Thanks!

Matt
This may do the trick for you.

HttpContext.Current.Request.ServerVariables("SERVER_NAME"))
 
Use this :

----------------------------------
<%@ Page Language="VB" %>
<html>
<head>
<title>Path Info</title>
</head>
<script runat="server">
Public Sub Page_Load(Sender As System.Object, E As System.EventArgs)
If Not Request.Url Is Nothing Then
path.text = Request.Url.ToString()
End If
End Sub
</script>
<html>
<body>
<form id="Form1" runat="server">
<p>
<asp:Label id="path" runat="server" /><BR>
</form>
</body>
</html>
--------



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
That will do it, too, but Request.Url will do it
just as well, with a bit more economy of bytes.

I've sometimes wondered why 2 properties are needed,
if one of them will do the same job with less bytes being used.

One of those properties should be deprecated,
and I suspect it should be the one which takes
more characters to write.

;-)



Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
 
Hello MattB,

You might try Request.Url.GetLeftPart(UriPartial.Authority) concatenated
with Request.ApplicationPath.
 
Back
Top