Reputation: 157
I am making a website in visual studio 2010 (in visual basic) and I really need to know how to get the URL from a VB statement (in the aspx.vb file, on page load).
Upvotes: 14
Views: 67713
Reputation: 57
Try this.
.Html Page
<div>
<h1> Url: </h1> <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
in .Vb Page
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.Url.ToString();
}
Upvotes: 0
Reputation: 12748
There's a few properties that can give you the information. Here's an example.
Dim url As String = HttpContext.Current.Request.Url.AbsoluteUri
Dim path As String = HttpContext.Current.Request.Url.AbsolutePath
Dim host As String = HttpContext.Current.Request.Url.Host
Upvotes: 20
Reputation: 1
VB.NET
Imports System.Net.Dns
Imports System.Net
Dim host As String = HttpContext.Current.Request.Url.Host
Dim hostname As IPHostEntry = Dns.GetHostEntry(host)
Dim ip As IPAddress() = hostname.AddressList
Label1.Text = ip(1).ToString()
Upvotes: 0