UrlRoutingHandler 类
定义
用作使你能够自定义 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.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.0 in Classic mode.
<system.web>
<httpHandlers>
<add verb="*" path="*.abc"
type="Contoso.Routing.CustomRoutingHandler" />
</httpHandlers>
</system.web>
下面的示例演示如何为在 IIS 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.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() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。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. |