获取vb.net中的当前URL

时间:2014-04-04 01:56:00

标签: asp.net vb.net visual-studio-2010 web

我正在visual studio 2010中创建一个网站(在visual basic中),我真的需要知道如何从VB语句中获取URL(在aspx.vb文件中,在页面加载时)。

3 个答案:

答案 0 :(得分:16)

可以为您提供few properties信息。这是一个例子。

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

答案 1 :(得分: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()

答案 2 :(得分:0)

试试这个。

  

.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();

    }
相关问题