查询选项' Format'不被允许.要允许它,请设置' AllowedQueryOptions'EnableQueryAttribute或QueryValidationSettings上的属性 [英] Query option 'Format' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings

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

问题描述

我在Web API控制器端点上遇到异常,希望能为解决该问题提供帮助.

I'm getting an exception on my Web API controller endpoint and I would appreciate some help solving it.

这是故事:

在我的Web API项目中,控制器公开了以下端点:

In my Web API project, a controller exposes the following endpoints:

我的Kendo UI Datagrid发出以下请求:

My Kendo UI Datagrid makes the following request:

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

验证请求中发送的ODataQueryOptions时遇到此异常:

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

不允许使用查询选项格式".要允许它,请在EnableQueryAttribute或QueryValidationSettings上设置"AllowedQueryOptions"属性.

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

但是我已经启用了所有查询选项:

But I've enabled all query options:

[EnableQuery(AllowedQueryOptions=AllowedQueryOptions.All)]

我在做什么错了?

推荐答案

最终设法弄清这点!

创建ODataValidationSettings对象后,我需要将AllowedQueryOptions更改为AllowedQueryOptions.All.默认情况下,除了格式"和跳过令牌"以外,所有其他选项都在那里.

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.

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

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