不同大小写的同名字符串参数被逗号分隔解析为一个字符串参数
Same name string parameters with differ case were parsed into one string parameter by comma delimited
在 javascript 请求中,我添加了两个名称相同但大小写不同的参数
*.setPostDataItem("FluentSearch", scope.search); (abc)
*.setPostDataItem("fluentSearch", scope.search); (abc)
我的服务器端代码 controller->action 将其解析为
string FluentSearch = abc, abc
因此在服务器参数中我们有一个字符串参数以逗号分隔的重复值。
我希望服务器应该解析请求并写入不带逗号的请求。
Asp.Mvc
在哪里以及为什么用逗号预先处理相同的参数两次?
之前是具体的action executor吗?
据我所知,客户端似乎发送了两个不同的参数,但服务器将它们视为一个并将它们组合为 csv。
看到这个答案
答案摘录
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).
现在查看 name value collection 它明确表示
The hash code provider dispenses hash codes for keys in the
NameValueCollection. The default hash code provider is the
CaseInsensitiveHashCodeProvider.
所以好像可以改成区分大小写。我没试过。你可以试试看。此行为对于查询字符串参数应该相同。
在 javascript 请求中,我添加了两个名称相同但大小写不同的参数
*.setPostDataItem("FluentSearch", scope.search); (abc)
*.setPostDataItem("fluentSearch", scope.search); (abc)
我的服务器端代码 controller->action 将其解析为
string FluentSearch = abc, abc
因此在服务器参数中我们有一个字符串参数以逗号分隔的重复值。
我希望服务器应该解析请求并写入不带逗号的请求。
Asp.Mvc
在哪里以及为什么用逗号预先处理相同的参数两次?
之前是具体的action executor吗?
据我所知,客户端似乎发送了两个不同的参数,但服务器将它们视为一个并将它们组合为 csv。
看到这个答案
答案摘录
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).
现在查看 name value collection 它明确表示
The hash code provider dispenses hash codes for keys in the NameValueCollection. The default hash code provider is the CaseInsensitiveHashCodeProvider.
所以好像可以改成区分大小写。我没试过。你可以试试看。此行为对于查询字符串参数应该相同。