Skip to content

RegexRouteConstraint should use Compiled Regex #46154

@eerhardt

Description

@eerhardt

Today, when using a regex route constraint, we create a new Regex:

Constraint = new Regex(
regexPattern,
RegexOptions.CultureInvariant | RegexOptions.IgnoreCase,
RegexMatchTimeout);

This should use the RegexOptions.Compiled as well. That way we aren't interpreting these regular expressions every time the route is inspected.

Our docs even say this should be using Compiled:

The ASP.NET Core framework adds RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.CultureInvariant to the regular expression constructor. See RegexOptions for a description of these members.

Metadata

Metadata

Assignees

Labels

Perfarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-routing

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions