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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks a lot, I deploy a WEB-API project, and use routing rules so there is no ? character.
OK yes it is different in routing. So is the single value supposed to be filter=address.id=100?
@LewisZou . is safe but yes can cause issue in routes if you don't take steps to fix. I updated answer to link to another SO answer about periods in routes.
Great, the link you give me is what i want to ask! Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.