Asp.net Azure-WebAPI+;OData-FilterQueryValidator-角色保持循环

Asp.net Azure-WebAPI+;OData-FilterQueryValidator-角色保持循环,asp.net,azure,odata,asp.net-web-api,asp.net-web-api-odata,Asp.net,Azure,Odata,Asp.net Web Api,Asp.net Web Api Odata,我刚刚部署了包含WebAPI的WCF web服务。在我将自己的过滤器查询验证器添加到项目之前,一切都正常。然后角色继续循环并重新启动。这是一个非常奇怪的问题,我无法确定这是什么原因。谢谢你的帮助 using System; using System.Linq; using System.Net; using System.Net.Http; using System.Web.Http; using System.Web.Http.OData.Query; using System.Web.Htt

我刚刚部署了包含WebAPI的WCF web服务。在我将自己的过滤器查询验证器添加到项目之前,一切都正常。然后角色继续循环并重新启动。这是一个非常奇怪的问题,我无法确定这是什么原因。谢谢你的帮助

using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Http.OData.Query;
using System.Web.Http.OData.Query.Validators;
using EMP.WebServices.api.Providers;
using Microsoft.Data.Edm.Library;
using Microsoft.Data.OData.Query.SemanticAst;

namespace EMP.WebServices.api.Validators
{
    public class EntityFilterByQueryValidator : FilterQueryValidator
    {
        public override void ValidateSingleValuePropertyAccessNode(SingleValuePropertyAccessNode propertyAccessNode, ODataValidationSettings settings)
        {
            var declaringType = propertyAccessNode.Property.DeclaringType;

            var edmEntityType = declaringType as EdmEntityType;

            var allowedProperties = TableStorageProvider.GetMetadataPropertyNames(edmEntityType.Name,
                                                                                  Constants.WebApi.V1).ToList();

            // Validate if we are accessing some sensitive property of WorkItem, such as Votes
            if (!allowedProperties.Contains(propertyAccessNode.Property.Name))
            {
                throw new HttpResponseException(new HttpResponseMessage
                {
                    Content = new StringContent(string.Format("{0} is an invalid filter property. {1}You can filter by these properties:{1}{2}.", propertyAccessNode.Property.Name, Environment.NewLine, string.Join(", " + Environment.NewLine, allowedProperties))),
                    ReasonPhrase = "Invalid Filter Property",
                    StatusCode = HttpStatusCode.BadRequest

                });
            }

            base.ValidateSingleValuePropertyAccessNode(propertyAccessNode, settings);
        }
    }
}

我从ODataQueryableSample()中看到,抛出ODataException似乎是首选技术。我建议你试试


如果您认为这里有一个bug,我建议您在上报告一个新bug。

如果您仅出于测试目的,删除抛出的异常,会发生什么?它仍然会继续循环使用。如果我对整个类进行注释,那就没问题了。您好,我用ODataException替换了HttpRespExc,角色仍然在循环使用。即使我试着在那里设置一个虚拟的空白类,这个角色也会继续循环使用。这样:使用System.Web.Http.OData.Query;使用System.Web.Http.OData.Query.Validators;使用Microsoft.Data.OData.Query.SemanticAst;命名空间EMP.WebServices.api.Validators{public class EntityFilterByQueryValidator:FilterQueryValidator{public override void ValidateSingleValuePropertyAccessNode(SingleValuePropertyAccessNode propertyAccessNode,ODataValidationSettings){}我在提到的地址提出了一个问题: