Get the exact url the user typed into the browser

后端 未结 6 754
轻奢々
轻奢々 2020-12-05 21:42

I would like to get the exact url that user typed into the browser. Of course I could always use something like Request.Url.ToString() but this does not give me

6条回答
  •  北海茫月
    2020-12-05 22:09

    It is possible, you just need to combining a few of the values from the request object to rebuild the exact url entered:

    Dim pageUrl As String = String.Format("{0}://{1}{2}", 
        Request.Url.Scheme, 
        Request.Url.Host, 
        Request.RawUrl)
    
    Response.Write(pageUrl)
    

    Entering the address http://yousite.com/?hello returns exactly:

    http://yousite.com/?hello
    

提交回复
热议问题