我有一个简单的Web API服务,大约有10个不同的GET操作,这些操作根据输入参数返回各种数据库记录的JSON输出。
对于一个特定的终结点,单个空格"“应该是有效的参数,但它将被转换为null。是否有解决此问题的方法?
例如,URL为:http://localhost:1234/DataAccess/RetrieveProductData?parameterOne=null¶meterTwo=574&problemParameter=%20¶meterThree=AB12
在控制器内我可以看到以下动作:
int? parameterOne => null
string parameterTwo => "574"
string problemParameter => null
string parameterThree => "AB12"
有没有办法实际得到:
string problemParameter => " "
还是这不可能?
2条答案
按热度按时间x4shl7ld1#
我通过添加一个
ParameterBindingRule
解决了这个问题,该ParameterBindingRule
具有足够的条件来匹配我遇到问题的确切参数:注册码:
StringParameterBinding.cs:
4zcjmb1e2#
您应该在客户端应用程序中执行此操作。是否要在Android上反序列化它?