0

If a queryString can contain a character '.'?

For example:

http://localhost:80/api/petstore/address/filter=address.id=100

In my memory it can not request to the correct host, so my old codes replace '.' to '^', and in the server replace '^' to '.'. The problem can't fix by encoding, because '.' will not encode.

I just want to double check if queryString can contain a character '.', and is there any better solution to fix this problem.

zzzzBov
  • 174,988
  • 54
  • 320
  • 367
Lewis Zou
  • 39
  • 1
  • 5

1 Answers1

1

Yes. . is a safe URL character.

A URL contains the name of the scheme being used (<scheme>) followed by a colon and then a string (the <scheme-specific-part>) whose interpretation depends on the scheme.

Scheme names consist of a sequence of characters. The lower case letters "a"--"z", digits, and the characters plus ("+"), period ("."), and hyphen ("-") are allowed.

source and percent encoding

Your querystring, however does not look correct as you don't even have a ?

address/?filter=address.id=100 would mean the value of filter is address.id=100.

address/?filter=address&id=100 would mean the value of filter is address and the value of id is 100.

Coming up with your own encoding standards probably isn't the best idea.

If this is for routes and not querystring, then please see this SO question about fix for period in routes. Although . is safe, it can cause problems in ASP.NET routes.

Community
  • 1
  • 1
MikeSmithDev
  • 15,731
  • 4
  • 58
  • 89