【问题标题】:Get current URL in vb.net在 vb.net 中获取当前 URL
【发布时间】:2014-05-16 03:18:52
【问题描述】:

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

【问题讨论】:

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


    【解决方案1】:

    有一个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
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        试试这个。

        .Html 页面

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

        在 .Vb 页面中

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

        【讨论】:

          猜你喜欢
          • 2019-07-19
          • 1970-01-01
          • 2010-10-19
          • 1970-01-01
          • 1970-01-01
          • 2011-06-18
          • 2019-09-23
          • 2014-01-03
          • 2011-03-13
          相关资源
          最近更新 更多