NonFileNameRouteConstraint Class

Definition

Constrains a route parameter to represent only non-file-name values. Does not validate that the route value contains valid file system characters, or that the value represents an actual file on disk.

public ref class NonFileNameRouteConstraint : Microsoft::AspNetCore::Routing::IRouteConstraint
public class NonFileNameRouteConstraint : Microsoft.AspNetCore.Routing.IRouteConstraint
public class NonFileNameRouteConstraint : Microsoft.AspNetCore.Routing.IRouteConstraint, Microsoft.AspNetCore.Routing.Matching.IParameterLiteralNodeMatchingPolicy
type NonFileNameRouteConstraint = class
    interface IParameterPolicy
    interface IRouteConstraint
type NonFileNameRouteConstraint = class
    interface IRouteConstraint
    interface IParameterPolicy
type NonFileNameRouteConstraint = class
    interface IRouteConstraint
    interface IParameterPolicy
    interface IParameterLiteralNodeMatchingPolicy
Public Class NonFileNameRouteConstraint
Implements IRouteConstraint
Public Class NonFileNameRouteConstraint
Implements IParameterLiteralNodeMatchingPolicy, IRouteConstraint
Inheritance
NonFileNameRouteConstraint
Implements

Remarks

This constraint can be used to disambiguate requests for dynamic content versus static files served from the application.

This constraint determines whether a route value represents a file name by examining the last URL Path segment of the value (delimited by /). The last segment must contain the dot (.) character followed by one or more non-(.) characters.

If the route value does not contain a / then the entire value will be interpreted as a the last segment.

The NonFileNameRouteConstraint does not attempt to validate that the value contains a legal file name for the current operating system.

Examples of route values that will be matched as non-file-names-description

  • /a/b/c : Final segment does not contain a ..
  • /a/b.d/c : Final segment does not contain a ..
  • /a/b.d/c/ : Final segment is empty.
  • : Value is empty

Examples of route values that will be rejected as file names-description

  • /a/b/c.txt : Final segment contains a . followed by other characters.
  • /hello.world.txt : Final segment contains a . followed by other characters.
  • hello.world.txt : Final segment contains a . followed by other characters.
  • .gitignore : Final segment contains a . followed by other characters.

Constructors

NonFileNameRouteConstraint()

Methods

Match(HttpContext, IRouter, String, RouteValueDictionary, RouteDirection)

Determines whether the URL parameter contains a valid value for this constraint.

Explicit Interface Implementations

IParameterLiteralNodeMatchingPolicy.MatchesLiteral(String, String)

Applies to