1

mij WCF WebApi 프로젝트를 MVC WebApi 프로젝트로 변환했습니다. 내 ApiController에이 모델을 게시 할 때MVC WebApi가 일반 모델로 작동하지 않습니다.

public class ObjectWaarde<T> 
{ 

    public ObjectWaarde(T objectType) 
    { 
     ObjectType = objectType; 
    } 

    /// <summary> 
    /// Gets the term to search for. 
    /// </summary> 
    public T ObjectType { get; set; } 

    public object Waardes 
    { 
     get 
     { 

      return ObjectType; 
     } 
     set { ObjectType = (T) value; } 
    } 
} 

이 오류가 표시됩니다 (HTTP 500) :

재산권 접근 'DeclaringMethod'객체 'System.RuntimeType'에서이 같은 속성을 가진 모델을 가지고 '메서드는 Type.IsGenericParameter가 true 인 Type에서만 호출 할 수 있습니다.'라는 예외가 발생했습니다.

답변

3

이 문제는 defaultbodymodelvalidator가 원인입니다. 내가 찾은 http://aspnetwebstack.codeplex.com/workitem/225

유일한 해결책은 modelvalidator을 해제했다 :

그것은 알려진 문제입니다.

GlobalConfiguration.Configuration.Services.Clear (typeof (IBodyModelValidator));