Tworzę witrynę internetową w Visual Studio 2010 (w wersji Visual Basic) i naprawdę muszę wiedzieć, jak uzyskać adres URL z instrukcji VB (w pliku aspx.vb, po załadowaniu strony).Pobierz aktualny adres URL w witrynie vb.net
9
A
Odpowiedz
13
Istnieje few properties, który może podać informacje. Oto przykład.
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
0
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()
0
Spróbuj tego.
.html Page
<div>
<h1> Url: </h1> <asp:Label ID="Label1" runat="server" Text=""></asp:Label>
</div>
w .Vb Page
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.Url.ToString();
}