Class HttpRoute
Represents a route class for self-host (i.e. hosted outside of ASP.NET).
public class HttpRoute : IHttpRoute
- Inheritance
-
HttpRoute
- Implements
- Inherited Members
Constructors
HttpRoute()
Initializes a new instance of the HttpRoute class.
public HttpRoute()
HttpRoute(string)
Initializes a new instance of the HttpRoute class.
public HttpRoute(string routeTemplate)
Parameters
routeTemplate
stringThe route template.
HttpRoute(string, HttpRouteValueDictionary)
Initializes a new instance of the HttpRoute class.
public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults)
Parameters
routeTemplate
stringThe route template.
defaults
HttpRouteValueDictionaryThe default values for the route parameters.
HttpRoute(string, HttpRouteValueDictionary, HttpRouteValueDictionary)
Initializes a new instance of the HttpRoute class.
public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints)
Parameters
routeTemplate
stringThe route template.
defaults
HttpRouteValueDictionaryThe default values for the route parameters.
constraints
HttpRouteValueDictionaryThe constraints for the route parameters.
HttpRoute(string, HttpRouteValueDictionary, HttpRouteValueDictionary, HttpRouteValueDictionary)
Initializes a new instance of the HttpRoute class.
public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens)
Parameters
routeTemplate
stringThe route template.
defaults
HttpRouteValueDictionaryThe default values for the route parameters.
constraints
HttpRouteValueDictionaryThe constraints for the route parameters.
dataTokens
HttpRouteValueDictionaryAny additional tokens for the route parameters.
HttpRoute(string, HttpRouteValueDictionary, HttpRouteValueDictionary, HttpRouteValueDictionary, HttpMessageHandler)
Initializes a new instance of the HttpRoute class.
public HttpRoute(string routeTemplate, HttpRouteValueDictionary defaults, HttpRouteValueDictionary constraints, HttpRouteValueDictionary dataTokens, HttpMessageHandler handler)
Parameters
routeTemplate
stringThe route template.
defaults
HttpRouteValueDictionaryThe default values for the route parameters.
constraints
HttpRouteValueDictionaryThe constraints for the route parameters.
dataTokens
HttpRouteValueDictionaryAny additional tokens for the route parameters.
handler
HttpMessageHandlerThe message handler that will be the recipient of the request.
Properties
Constraints
Gets the constraints for the route parameters.
public IDictionary<string, object> Constraints { get; }
Property Value
- IDictionary<string, object>
The constraints for the route parameters.
DataTokens
Gets any additional data tokens not used directly to determine whether a route matches an incoming HttpRequestMessage.
public IDictionary<string, object> DataTokens { get; }
Property Value
- IDictionary<string, object>
Any additional data tokens not used directly to determine whether a route matches an incoming HttpRequestMessage.
Defaults
Gets the default values for route parameters if not provided by the incoming HttpRequestMessage.
public IDictionary<string, object> Defaults { get; }
Property Value
- IDictionary<string, object>
The default values for route parameters if not provided by the incoming HttpRequestMessage.
Handler
Gets or sets the http route handler.
public HttpMessageHandler Handler { get; }
Property Value
- HttpMessageHandler
The http route handler.
RouteTemplate
Gets the route template describing the URI pattern to match against.
public string RouteTemplate { get; }
Property Value
- string
The route template describing the URI pattern to match against.
Methods
GetRouteData(string, HttpRequestMessage)
Determines whether this route is a match for the incoming request by looking up the HttpRouteData for the route.
public virtual IHttpRouteData GetRouteData(string virtualPathRoot, HttpRequestMessage request)
Parameters
virtualPathRoot
stringThe virtual path root.
request
HttpRequestMessageThe HTTP request.
Returns
- IHttpRouteData
The HttpRouteData for a route if matches; otherwise null.
GetVirtualPath(HttpRequestMessage, IDictionary<string, object>)
Attempts to generate a URI that represents the values passed in based on current values from the HttpRouteData and new values using the specified HttpRoute.
public virtual IHttpVirtualPathData GetVirtualPath(HttpRequestMessage request, IDictionary<string, object> values)
Parameters
request
HttpRequestMessageThe HTTP request message.
values
IDictionary<string, object>The route values.
Returns
- IHttpVirtualPathData
A HttpVirtualPathData instance or null if URI cannot be generated.
ProcessConstraint(HttpRequestMessage, object, string, HttpRouteValueDictionary, HttpRouteDirection)
Determines whether this instance equals a specified route.
protected virtual bool ProcessConstraint(HttpRequestMessage request, object constraint, string parameterName, HttpRouteValueDictionary values, HttpRouteDirection routeDirection)
Parameters
request
HttpRequestMessageThe HTTP request.
constraint
objectThe constraints for the route parameters.
parameterName
stringThe name of the parameter.
values
HttpRouteValueDictionaryThe list of parameter values.
routeDirection
HttpRouteDirectionOne of the enumeration values of the
enumeration.
Returns
- bool
true if this instance equals a specified route; otherwise, false.