这是我创建的wcf restful服务。
[OperationContract]
[WebInvoke( Method="GET",
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "GiveMenu")]
Stream GiveMenu();
[OperationContract]
[WebInvoke(Method = "POST",
BodyStyle = WebMessageBodyStyle.Wrapped,
ResponseFormat = WebMessageFormat.Json,
RequestFormat = WebMessageFormat.Json,
UriTemplate = "GetOrder/{order_json}")]
bool GetOrder(string order_json);
在这里,我可以从GiveMenu方法中获取数据:
http://localhost:5203/Service1.svc/GiveMenu
但是当我试图发布这样的数据时:
http://localhost:5203/Service1.svc/GetOrder/{"order":[{"Tb_id":1,"Item_id":1,"Quantity":1,"Add_Details":"null"}]}
然后我说:
HttpException (0x80004005) : A potentially dangerous Request.Path value was detected from the client (:).
然后我在我的网络配置文件中进行了更正:
<httpRuntime targetFramework="4.5" requestPathInvalidCharacters=""/>
然后我展示了方法不允许这样:
如何使数据发布并解决此错误。
答案 0 :(得分:0)
在这里回答:Getting "A potentially dangerous Request.Path value was detected from the client (&)"
您可以在web.config文件中尝试以下操作。
<system.web>
<httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
<pages validateRequest="false" />
</system.web>