Reputation: 4232
I'm porting an old API project to .NET Core 3.1 API project. All endpoints in old are working fine. While testing the new API on local IIS 10/Windows 10 I'm getting this error:
System.ArgumentException: In a route parameter, '{' and '}' must be escaped with '{{' and '}}'. (Parameter 'routeTemplate')
The specific route in question is not shown in the error. So I am including all routes here.
[Route("department/{id:int}")]
[Route("program/{deptId:int}")]
[Route(@"employee/{samId:regex(^[[A-Za-z0-9._-]]{3,30}$)}")]
[Route(@"homepage/{samId:regex(^[[a-zA-Z0-9_.-]]{3,30}$)}")]
On #2 and #3 I have double [
and double ]
because I was getting error on those as well earlier when they were single.
Upvotes: 3
Views: 3060
Reputation: 2932
According to the error message
System.ArgumentException: In a route parameter, '{' and '}' must be escaped with '{{' and '}}'. (Parameter 'routeTemplate')
you need to add one more {}
in front, like this:
[Route(@"test/{{samId:regex(^[[A-Za-z0-9._-]]{3,30}$)}}")]
Upvotes: 1