asp.net Request獲取url信息的各種方法比較
更新時(shí)間:2010年03月04日 19:42:21 作者:
Request 獲取url信息的各種方法比較
本頁地址: Request.URL;
上頁地址:
Request.UrlReferrer
Request.ServerViables["http_referer"]
Request.RawUrl
Request.RawUrl.QueryAndPath
System.IO.Path.GetFileName(Request.FilePath.ToString())
在ASP.NET編程中經(jīng)常需要用Request獲取url的有關(guān)信息,Request中有多種方法獲取 url信息,但我經(jīng)常忘了各種方法的具體作用,今天我就寫了個(gè)測試程序,將各種方法得到的結(jié)果列出來,以后用時(shí)直接參考一下就行了。
測試的url 地址是http://www.test.com/testweb/default.aspx, 結(jié)果如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PathInfo:
Request.PhysicalApplicationPath: E:\WWW\testweb\
Request.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx
當(dāng)url中帶參數(shù)時(shí)可以使用:
HttpContext.Current.Request.Url.PathAndQuery.ToString()
上頁地址:
復(fù)制代碼 代碼如下:
Request.UrlReferrer
Request.ServerViables["http_referer"]
Request.RawUrl
Request.RawUrl.QueryAndPath
System.IO.Path.GetFileName(Request.FilePath.ToString())
在ASP.NET編程中經(jīng)常需要用Request獲取url的有關(guān)信息,Request中有多種方法獲取 url信息,但我經(jīng)常忘了各種方法的具體作用,今天我就寫了個(gè)測試程序,將各種方法得到的結(jié)果列出來,以后用時(shí)直接參考一下就行了。
測試的url 地址是http://www.test.com/testweb/default.aspx, 結(jié)果如下:
復(fù)制代碼 代碼如下:
Request.ApplicationPath: /testweb
Request.CurrentExecutionFilePath: /testweb/default.aspx
Request.FilePath: /testweb/default.aspx
Request.Path: /testweb/default.aspx
Request.PathInfo:
Request.PhysicalApplicationPath: E:\WWW\testweb\
Request.PhysicalPath: E:\WWW\testweb\default.aspx
Request.RawUrl: /testweb/default.aspx
Request.Url.AbsolutePath: /testweb/default.aspx
Request.Url.AbsoluteUri: http://www.test.com/testweb/default.aspx
Request.Url.Host: www.test.com
Request.Url.LocalPath: /testweb/default.aspx
當(dāng)url中帶參數(shù)時(shí)可以使用:
HttpContext.Current.Request.Url.PathAndQuery.ToString()
您可能感興趣的文章:
- Asp.net內(nèi)置對(duì)象之Request對(duì)象(概述及應(yīng)用)
- Asp.net中Request.Url的各個(gè)屬性對(duì)應(yīng)的意義介紹
- ASP.NET從客戶端中檢測到有潛在危險(xiǎn)的request.form值的3種解決方法
- asp.net HttpWebRequest自動(dòng)識(shí)別網(wǎng)頁編碼
- asp.net下Request.QueryString取不到值的解決方法
- ASP.NET筆記之 Request 、Response 與Server的使用
- asp.net中Request.QueryString與Request.Param的區(qū)別分析
- Asp.net response對(duì)象與request對(duì)象使用介紹
- asp.net request.PathInfo實(shí)現(xiàn)的url重寫
- asp.net實(shí)現(xiàn)遍歷Request的信息操作示例
相關(guān)文章
使用vs2019加.net core 對(duì)WeiApi的創(chuàng)建過程詳解
這篇文章主要介紹了使用vs2019加.net core 對(duì)WeiApi的創(chuàng)建,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07CHECKBOX 的全選、取消及跨頁保存的實(shí)現(xiàn)方法
CHECKBOX的操作在頁面中很常見,比如全選、取消、跨頁保存等等,下面有個(gè)不錯(cuò)的示例,大家可以嘗試操作下2013-10-10Asp.Net使用服務(wù)器控件Image/ImageButton顯示本地圖片的方法
Image/ImageButton服務(wù)器控件顯示本地的圖片,實(shí)現(xiàn)思路是數(shù)據(jù)庫中存放了圖片的相對(duì)地址,讀取數(shù)據(jù)庫中的地址,用控件加載顯示圖片。具體實(shí)現(xiàn)步驟大家參考下本文2017-08-08詳解ASP.NET Core 網(wǎng)站發(fā)布到Linux服務(wù)器
本篇文章主要介紹了ASP.NET Core 網(wǎng)站發(fā)布到Linux服務(wù)器 。具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。2017-04-04ASP.NET CORE學(xué)習(xí)教程之自定義異常處理詳解
這篇文章主要給大家介紹了關(guān)于ASP.NET CORE學(xué)習(xí)教程之自定義異常處理的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-01-01如何在網(wǎng)站級(jí)別動(dòng)態(tài)更改主題
如何在網(wǎng)站級(jí)別動(dòng)態(tài)更改主題...2007-04-04