2014-04-04 15 views
9

Tôi đang tạo một trang web trong phòng thu trực quan 2010 (trong hình ảnh cơ bản) và tôi thực sự cần biết cách lấy URL từ một câu lệnh VB (trong tệp aspx.vb, khi tải trang).Nhận URL hiện tại trong vb.net

Trả lời

13

Có một số few properties có thể cung cấp cho bạn thông tin. Đây là một ví dụ.

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

Hãy thử điều này.

.html Trang

<div> 
    <h1> Url: </h1> <asp:Label ID="Label1" runat="server" Text=""></asp:Label> 
    </div> 

trong .vb Trang

protected void Page_Load(object sender, EventArgs e) 
    { 
     Label1.Text = Request.Url.ToString(); 

    } 
Các vấn đề liên quan