-1

In javascript request I added two parameters with same name but different case

  1. *.setPostDataItem("FluentSearch", scope.search); (abc)
  2. *.setPostDataItem("fluentSearch", scope.search); (abc)

My server side code controller->action parsed it as

string FluentSearch = abc, abc

So at the server parameter we have at one string parameters duplicate value by comma delimited.

I expect that server should parse request and wrote them ones without comma.
Where and why Asp.Mvc pre works same parameters twice by comma? Is it specific action executor before?

Gsk
  • 2,929
  • 5
  • 22
  • 29
  • Welcome to Stack Overflow! I indented your code sample by 4 spaces so that it renders properly; I also added as code some specific words in your explanation. Formatting your code and question properly improves readability, so more people will understand what you're asking and will be more prone to answering. Check the [editing help](https://stackoverflow.com/editing-help) for more information on formatting. – Gsk Jan 22 '19 at 13:40
  • Thanks for advice! – Yaroslav Orlov Jan 22 '19 at 13:43

1 Answers1

0

As far as I could understand, it seems that client is sending two different parameters but server is treating them as one combining them as csv.

See this answer https://stackoverflow.com/a/32127030/1384239

Excerpt from answer

It is entirely up to that authority on whether this stuff is case-sensitive or not.

In the case of C# and IIS, the backing store for the parsed query string in the HttpRequest object is a System.Collections.Specialized.NameValueCollection which happens to be case-insensitive (by default).

Now looking at name value collection it specifically says that

The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.

So it seems that it can be changed to become case sensitive. I did not try that. You might try that. This behavior should be same for query string parameters.

Chaturvedi Dewashish
  • 1,469
  • 2
  • 15
  • 39