get full URL?

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
 
V

vMike

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"))
 
J

Juan T. Llibre

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>
--------
 
J

Juan T. Llibre

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.

;-)
 
M

Matt Berther

Hello MattB,

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top