RouteDirection 枚举


指示 ASP.NET 路由正处理来自客户端的 URL 还是正在生成 URL。Indicates whether ASP.NET routing is processing a URL from a client or generating a URL.

public enum class RouteDirection
public enum RouteDirection
type RouteDirection = 
Public Enum RouteDirection


IncomingRequest 0

正在处理来自客户端的 URL。A URL from a client is being processed.

UrlGeneration 1

正在根据路由定义创建 URL。A URL is being created based on the route definition.


你可以使用 ASP.NET 路由来处理 URL, 方法是将其与 ASP.NET 应用程序中的路由定义相匹配, 或者生成基于路由定义的 Url。You can use ASP.NET routing to process a URL by matching it to the route definitions in an ASP.NET application, or to generate URLs that are based on the route definitions. RouteDirection枚举提供有助于区分这些方案的值。The RouteDirection enumeration provides values that help you differentiate between these scenarios. 这很有用, 因为路由约束的处理方式取决于方案。This is useful because route constraints are processed differently depending on the scenario. 如果通过实现IRouteConstraint接口创建自定义路由约束, 则可能必须检查Match方法中routeDirection参数的值, 以区分方案。If you create a custom route constraint by implementing the IRouteConstraint interface, you might have to check the value of the routeDirection parameter in the Match method to differentiate the scenarios.