ASP.NET裏得到網站的域名

 Dim url, host_url, no_http, host_name As String '定義變量
url = HttpContext.Current.Request.Url.ToString '獲取當前頁的URL
no_http = url.Substring(url.IndexOf("//") + 2) '截取去掉HTTP://的URL
host_url = "http://" & no_http.Substring(0, no_http.IndexOf("/") + 1) '組合成當前網站的域名

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章