首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不允许的方法、检测到的潜在威胁或restful wcf post数据

不允许的方法、检测到的潜在威胁或restful wcf post数据
EN

Stack Overflow用户
提问于 2014-05-06 17:30:00
回答 1查看 580关注 0票数 1

这是我创建的wcf restful服务。

代码语言:javascript
复制
    [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方法中获取数据:

代码语言:javascript
复制
http://localhost:5203/Service1.svc/GiveMenu

但是当我尝试像这样发布数据时:

代码语言:javascript
复制
http://localhost:5203/Service1.svc/GetOrder/{"order":[{"Tb_id":1,"Item_id":1,"Quantity":1,"Add_Details":"null"}]}

然后我说:

代码语言:javascript
复制
HttpException (0x80004005) : A potentially dangerous Request.Path value was detected from the client (:).

然后我在我的web配置文件中做了以下更正:

代码语言:javascript
复制
<httpRuntime targetFramework="4.5" requestPathInvalidCharacters=""/>

然后我展示了不允许使用的方法,如下所示:

我应该怎么做才能让数据发布工作并解决这个错误。

EN

回答 1

Stack Overflow用户

发布于 2014-07-11 00:42:43

在这里回答:Getting "A potentially dangerous Request.Path value was detected from the client (&)"

您可以在web.config文件中尝试执行以下操作。

代码语言:javascript
复制
<system.web>
    <httpRuntime requestPathInvalidCharacters="" requestValidationMode="2.0" />
    <pages validateRequest="false" />
</system.web>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23490850

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档