duongthaiha
duongthaiha

Reputation: 855

.net core webapi route attribute regex with /

I am trying to find a way to match a route when request contains multiple path and URL always end with /end

For example:

domain.com/api/path1/path2/path3/end

domain.com/api/path1/path2/path3/path4/end

I tried [Route("api/{p:regex(([[\\w-]]*\\/){{1,}})}end")] but this didn't work.

Any recommendation?

Upvotes: 2

Views: 1398

Answers (1)

user7907891
user7907891

Reputation:

regex pattern must be as below:

^(?:[a-z0-9.]+(\/))*end

Note that in the C# language "\" is the operator character. So you must use \\ instead of \.

Upvotes: 3

Related Questions