查询选项'格式化'是不允许的。要允许它,设置在EnableQueryAttribute或QueryValidationSettings了“AllowedQueryOptions'属性 [英] Query option 'Format' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings

查看:531
本文介绍了查询选项'格式化'是不允许的。要允许它,设置在EnableQueryAttribute或QueryValidationSettings了“AllowedQueryOptions'属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到我的Web API控制器终点异常,我真的apricaite一些帮助解决这个:

下面的故事:

我的Web API项目控制器公开以下终点:

我的剑道UI Datagrid中提出了以下要求:

<$p$p><$c$c>http://localhost:63865/api/employees/GetAll?$callback=jQuery21109420544053427875_1410883352953&%24inlinecount=allpages&%24format=json&%24top=5

在验证请求发出的ODataQueryOptions,我得到这个异​​常:


  

查询选项格式是不允许的。要允许它,设置在EnableQueryAttribute或QueryValidationSettings了AllowedQueryOptions'属性。


但其实我已经启用的所有查询选项

  [EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All)

我是我做错了吗?


解决方案

终于设法得到这条底线!

创建ODataValidationSettings反对我需要的AllowedQueryOptions改为AllowedQueryOptions.All后。被默认所有选项都存在,除了格式和SkipToken。

不管怎样,希望这可以帮助其他人面临着同样的问题。

I'm getting an exception on my Web API controller end-point and I would really apricaite some help in solving this:

Here is the story:

My Web API project a controller exposes the following End-Point:

My Kendo UI Datagrid makes the following request:

http://localhost:63865/api/employees/GetAll?$callback=jQuery21109420544053427875_1410883352953&%24inlinecount=allpages&%24format=json&%24top=5

When validating the ODataQueryOptions sent in the request, I'm getting this exception:

Query option 'Format' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings.

But I've actually enabled all query options

[EnableQuery(AllowedQueryOptions=AllowedQueryOptions.All)]

What I'm I doing wrong ?

解决方案

Finally manage to get to the bottom of this!

After creating the ODataValidationSettings object I needed to change the AllowedQueryOptions to AllowedQueryOptions.All. Be default all options are there except the Format and SkipToken.

Anyway, hope this may help anyone else facing the same issue.

这篇关于查询选项'格式化'是不允许的。要允许它,设置在EnableQueryAttribute或QueryValidationSettings了“AllowedQueryOptions'属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆