UrlRoutingHandler 類別

定義

做為多個類別的基底類別 (Base Class),這些類別讓您能自訂 ASP.NET 路由處理要求的方式。Serves as base class for classes that enable you to customize how ASP.NET routing processes a request.

public ref class UrlRoutingHandler abstract : System::Web::IHttpHandler
public abstract class UrlRoutingHandler : System.Web.IHttpHandler
type UrlRoutingHandler = class
    interface IHttpHandler
Public MustInherit Class UrlRoutingHandler
Implements IHttpHandler
繼承
UrlRoutingHandler
實作

備註

您可以藉由將副檔名對應至特定的路由處理常式, 而不是使用UrlRoutingModule類別做為每個要求的路由處理常式, 自訂 ASP.NET 路由處理要求的方式。You can customize how ASP.NET routing handles requests by mapping a file name extension to a particular routing handler instead of by using the UrlRoutingModule class as the routing handler for every request.

若要自訂 ASP.NET 路由如何處理具有特定副檔名之 URL 的要求, 您可以建立衍生自UrlRoutingHandler類別的類別。To customize how ASP.NET routing handles a request for a URL with a specific file name extension, you create a class that derives from the UrlRoutingHandler class. 例如, 您可以建立自訂的路由處理常式, 以處理具有副檔名.abc之檔案的要求。For example, you can create a customized routing handler that processes requests for a file that has the extension .abc.

若要註冊特定副檔名的自訂處理常式, 您必須將該處理常式加入 web.config 檔案中。To register a customized handler for a particular file name extension, you must add that handler in the Web.config file. 下列範例示範如何為在 IIS 6.0 或IIS 7.0IIS 7.0傳統模式中執行的 ASP.NET 網站註冊自訂處理常式。The following example shows how to register a customized handler for an ASP.NET Web site that is running in IIS 6.0 or IIS 7.0IIS 7.0 in Classic mode.

<system.web>  
  <httpHandlers>  
    <add verb="*" path="*.abc"   
        type="Contoso.Routing.CustomRoutingHandler" />  
  </httpHandlers>  
</system.web>  

下列範例顯示如何針對在中IIS 7.0IIS 7.0執行的 ASP.NET 網站註冊相同的處理常式。The following example shows how to register the same handler for an ASP.NET Web site that is running in IIS 7.0IIS 7.0.

<system.webServer>  
  <handlers>  
    <add verb="*" path="*.abc"  
        type="Contoso.Routing.CustomRoutingHandler"   
        resourceType="Unspecified" />  
  </handlers>  
</system.webServer>  

建構函式

UrlRoutingHandler()

初始化 UrlRoutingHandler 類別的新執行個體。Initializes a new instance of the UrlRoutingHandler class.

屬性

IsReusable

取得值,這個值表示另一個要求是否可以使用 UrlRoutingHandler 執行個體。Gets a value that indicates whether another request can use the UrlRoutingHandler instance.

RouteCollection

取得或設定 ASP.NET 應用程式之定義的路徑集合。Gets or sets the collection of defined routes for the ASP.NET application.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
ProcessRequest(HttpContext)

處理與路徑相符的 HTTP 要求。Processes an HTTP request that matches a route.

ProcessRequest(HttpContextBase)

處理與路徑相符的 HTTP 要求。Processes an HTTP request that matches a route.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
VerifyAndProcessRequest(IHttpHandler, HttpContextBase)

在衍生類別中覆寫時,驗證 HTTP 處理常式並執行處理要求所需的步驟。When overridden in a derived class, validates the HTTP handler and performs the steps that are required to process the request.

明確介面實作

IHttpHandler.IsReusable

取得值,這個值表示另一個要求是否可以使用 UrlRoutingHandler 執行個體。Gets a value that indicates whether another request can use the UrlRoutingHandler instance.

IHttpHandler.ProcessRequest(HttpContext)

處理與路徑相符的 HTTP 要求。Processes an HTTP request that matches a route.

適用於

另請參閱