0
如何使用&符号查询字符串中的Web Api操作?在查询字符串中使用与符号实现Web Api操作
这工作:
http://localhost:12345/api/MyController/MyAction?user=test&pw=abc123
这不:
http://localhost:12345/api/MyController/MyAction?user=test&pw=abc123
错误消息:
{
"message": "No HTTP resource was found that matches the request URI 'http://localhost:12345/api/MyController/MyAction?user=test&pw=abc123'.",
"messageDetail": "No action was found on the controller 'MyController' that matches the request."
}
我认为网页API将查询字符串参数自动解码,但apperently它不...
这对我来说很明显。关键是我怎样才能使它与&符合使用?该URL出现在XML文件中,所以我必须将其转义。 – iappwebdev
HTTP规范不会允许您以这种方式发送它,并将其解释为两个查询字符串变量。你的选择是1)在发送之前将它缩小或2)让你的API只接受“用户”,然后在C#中解析它。 #2似乎很无礼 - #1会更有意义。由于我不确定在调用API的代码中使用哪种语言,因此我不知道如何提示如何忽略它。 – grayimp
好吧,我会和#1一起去,谢谢! – iappwebdev