M0_salah
M0_salah

Reputation: 41

.NET - Encoding works on localhost but not on dev environment

I have an endpoint

[HttpGet, Route("ICDCodes/BySearchText/{searchText}", Name = "GetIcdCode")]

When I'm trying to pass some string with special characters (50$%b/de90 - for example) on localhost - 204 is returned (as it should be because in database there's no such code), but the same endpoint with the same parameter on Dev environment returns 404.

In Appinsights URL for dev looks like this - ICDCodes/BySearchText/50$%25b/de90

Is this because slash is not encoded, or because "%" is encoded to "%25", or both? But why it works locally?

Upvotes: 0

Views: 114

Answers (1)

sa-es-ir
sa-es-ir

Reputation: 5052

Technically it shouldn't work even on your local because there is a / in the url and it means new route section. by the way you can use * for route parameter and it ignore the / in the url as a new route section, like this:

[HttpGet, Route("ICDCodes/BySearchText/{*searchText}", Name = "GetIcdCode")]

Upvotes: 1

Related Questions