Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

FromQuery invalid Dictionary parameters values when dot sign inside #6746

Closed
jsobus-neurosys opened this issue Sep 1, 2017 · 2 comments
Closed

Comments

@jsobus-neurosys
Copy link

Problem when getting a Dictionary<string, string> as all parameters passed to the controller in query string. I am using [FromQuery] for that case but when parameter got a dot sign (.) inside it's name it get parsed wrong. What is more I debugged it and inside Response.Query object it is handled properly so the problem probably is somewhere in DictionaryModelBinderProvider. Below screenshot to the debugged code:

image

Full query string sent to the controller:

?query=&InspectionType=Safety&ItemType=InspectionPoint&RecordParentGUID=9275bee2-0a2d-461c-8835-51880e76f035&parent.ResultClassCode=parent.ResultClassCode

Already opened a question on SO about that problem so will add also a link here: https://stackoverflow.com/questions/45997570/asp-net-core-fromquery-getting-invalid-parameters-with-dot-sign-inside

@jsobus-neurosys
Copy link
Author

As a workaround I can use Request.Query.ToDictionary(kvp => kvp.Key, kvp => kvp.Value) but the question is if that is a bug or not?

@Eilon
Copy link
Member

Eilon commented Sep 11, 2017

Hi @jsobus-neurosys sorry for the delay.

This is by-design, per the answer listed at https://stackoverflow.com/a/46003081/31668.

The . character is indeed a special character that denotes a sub-property (just like in C#). The other special characters are [ and ], which denote indexers (also, just like in C#).

These patterns are fairly common in various binding systems. jQuery, PHP, and other frameworks follow similar patterns.

@Eilon Eilon closed this as completed Sep 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants