简体   繁体   中英

Get Referral URL on page load in VB

How can I get the URL of current page on onPageLoad() event.

Dim URL = Request.UrlReferrer.ToString

I got the URL on button click, but I need to get the result on PageLoad itself.

Can any one suggest me on this case?

Yes, you can use it in Page_Load . But first You have to check if UrlReferrer isn't nothing .

There is example :

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  Dim URL As String = ""
  If Request.UrlReferrer IsNot Nothing Then
    URL = Request.UrlReferrer.ToString()
  End If
End Sub

I rarely build with VB. I use C#. However, There is no reason that Request.UrlReferrer would not be available in the Page_Load method in VB. It's available in C#.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM