我是使用asp .net中的web api开发Rest服务的新手。
我尝试在查询字符串中发送图像字节。但是我无法在查询字符串中发送图像字节。
我在GET和Post中有基本概念。
发布数据没有任何限制。
此处我也添加了我的示例代码。
[AcceptVerbs("GET", "POST")]
public string PostRoute(string routingRequestTemplate)
{
return routingRequestTemplate;
}
我的字符串值:
hjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjsgbYwjolIo2s2YoqTF4YeSWSmTLmm1UNwuk/W4340Jm2jmTwLsRptpFkMNmgcKaZtZse1SAoSdfm9u0MpAMXgj5ZWHk3KqEs4qRrQQYcjfpyFab3HSqajJ4DCwIXu7NCBwV9SrAUKRr8DR4poJ3M0zFo6m9EUF+uA5uFdlKG7w9118kehITj2k1N+m8kJl2riTFI3iO8gjOUfHyQrVw32E3Mg+yW0pF3AuJ6L2sV7s5vHzu19066VN9I/DyBTwqXl45u1QaolyD0Ufw7OFcK+A4KT6C5mP7v5ew+dTYh1CeB/i5Vr5P5MEYvApkC3jM5UmzgJ+lM7uYGj+VztNO4Khyl3qG8OPQOH4dncAPXP95ka/lfflcrIAKujLNxH0p3/ej4Ekur4bNAq3dXGtr/bs8wI2K3FS6r3pHUHp/Gp3PXmD89QImF5Yw/s8iup6+4PsP8TU/F/gCX8pFzMTvkQweg4pQhQou8iSXxwXenuZOy7fB+wmdt30AFxhERSanMbf2Blu7u9jbA8eeGtt8Pbu6htDENE3tEPwyeTa4IU1xK04CT0ytrDhzsktFIltVOsvEOyuF7yxuhIt+rJsqdm38AR4sLmNnl8QZ/Nva2cX4/CJ+H5lUvp+HptcubkhaATwNPGmPcje1EzyWzlK4iBl5DFWumOAFuHtC08wcVjc2DJA7eIs8vl5/j4ZHs2o+XDELz4uZ1/tE8JhOEcVzRBq5/oIpFV6YjIQqhckTX62YAImZjT55hrXNzRPB26XZXSGYsbnnuMSNBV1USVG8sw6rzmXKv5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c8REZOTyLOi7dHFXyrTJ/s5c8iA5Xg+EZCOo+pGUm3GH+PbT9TBo8uyY5GUS6X/S1P40a644++YfQweHjO/lvycCM1PBdWV1Azdl/ZU3KCkgu0o23/dU3WwKul4gXgrmmELxRjFGavoTPDMAKffBe3K5Hudx19CDBqnXz5Gi+XV7C0uoa1JOkWswjKccbnX+LCwDBzgB10tw6ATuxrCjxGtMrNMp2yBR4j2wJGgcbNstOngKeUj309I+F7lHm6c1S/AF1i//Qspl8tYJkASkplTRoBktyf2Sbbr3C/ifm/VQrmeEuPOpcj3GzK4HH0Is/G4BkPkVI+Ppl+PmAS7brpfo+39OIX5t9KmYsL359Cx8Mn6JuewdDsHEafvWCfMHG7y9/LdoMzc2iZfIKrg3dZbEDoCLn0Kx0RWFgGj0NmOWy5LI/yMqWiIlubjF4YsO30aQCYz76fl/DJiEOeSvh2EsRunKQrPtNzG7/0DiRtv21uc5qJ6mO0nSSu5ViFTB6r88hNcUIz7WqZPM4pE/ACqjzKWxd1FHgChcAhqiSgSDmU9AGluEC+S/JZIDLTZH/pO3qporKf4V41eKoQdHPkQvJ40sfbATxVHuUAxduuQAKHAYi4RUn4ShGoURhgFAok+5TxWQHOONb2czjiu2nFkxwe1U7yeDJs5mF5lE+qVHgARxhqB/e31R9zsA1SvvemwVOKR/BuETxWIquUCqtU7FaNnKohDSU0+5nqeWyzX0rglRO8aubyNosFbGOMHVRNX9seBTtJwZPSd1WLJ8HFpuIRPA9TKr4gI1v2VfTN2aObY+cHIWXwqjR4+oHbxQNnGrzN4CKXwYVb+ngET6pU/EwJqLFFh0W3GrpdQCdKbhm8CoLHqNYtoxd1ETX/QoO3y5tgZ5ca79pSBk8pHmecsVhAg6fBs+wBrIHH4TKleA3wEDxvDXN5XFlAJq6oyS3x6Nb/rwOwdxlIC3gcAtLgadWzpHqpg0
URL: http://localhost:64528/api/controller/PostRoute?routingRequestTemplate=string
我遇到错误
在Web服务器上配置请求筛选以拒绝请求,因为查询字符串太长。
答案 0 :(得分:0)
查询字符串有大小限制,下面是详细信息
Querystring的最大长度取决于浏览器不依赖于asp.net。
使用Post动词尝试以下代码:
[HttpPost]
public ActionResult PostRoute(HttpPostedFileBase file) {
}
此链接也可以帮助您:
答案 1 :(得分:0)
What is the maximum possible length of a query string?
您的图片需要非常小,并且base64编码,或者使网址安全。网址长度非常有限。我建议把它放在POST体内。