Page.RouteData Page.RouteData Page.RouteData Page.RouteData Property

定義

取得目前 RouteData 執行個體的 RequestContext 值。Gets the RouteData value of the current RequestContext instance.

public:
 property System::Web::Routing::RouteData ^ RouteData { System::Web::Routing::RouteData ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Web.Routing.RouteData RouteData { get; }
member this.RouteData : System.Web.Routing.RouteData
Public ReadOnly Property RouteData As RouteData

屬性值

目前 RouteData 執行個體的 RequestContext 值。The RouteData value of the current RequestContext instance.

備註

如果網頁正在執行以回應透過 ASP.NET 路由提出的要求,此屬性可讓您存取傳遞為路由資料的 URL 參數值。If a page is running in response to a request made through ASP.NET routing, this property provides access to the URL parameter values that were passed as route data. 如果頁面執行以回應實體 URL,而不是路由 URL,則此屬性為nullIf the page runs in response to a physical URL instead of a route URL, this property is null. 下列範例顯示如何將名year為的 URL 參數值解壓縮。The following example shows how to extract the value of a URL parameter that is named year.

Dim year As Integer = Convert.ToInt32(Page.RouteData.Values("year"))  
int year = Convert.ToInt32(Page.RouteData.Values["year"])  

如果{locale}/{year}路由是使用網域contoso.com的 URL 模式定義的,而且如果要求的 URL 是,則當此year程式contoso.com/US/2010代碼執行時,將會包含值 "2010"。If the route is defined by using the URL pattern {locale}/{year} for the domain contoso.com, and if the requested URL is contoso.com/US/2010, year will contain the value "2010" when this code runs.

如需 ASP.NET 路由的詳細資訊,請參閱ASP.NET 路由For more information about ASP.NET routing, see ASP.NET Routing.

適用於

另請參閱