2015-08-25 68 views
-1

我收到以下錯誤,可能是什麼原因。IBodyModelValidator你是否缺少類型映射?

我剛剛創建了一個新的控制器,其他控制器的工作正常。

Error: 

Resolution of the dependency failed, type = "System.Web.Http.Validation.IBodyModelValidator", name = "(none)". 

Exception occurred while: while resolving. 

Exception is: InvalidOperationException - The current type, System.Web.Http.Validation.IBodyModelValidator, is an interface and cannot be constructed. Are you missing a type mapping? 

----------------------------------------------- 

At the time of the exception, the container was: 



    Resolving System.Web.Http.Validation.IBodyModelValidator,(none) 

它落在下面。

public object GetService(Type serviceType) 
     { 
      if (this.Container == null) 
      { 
       throw new ObjectDisposedException("this", "This scope has already been disposed."); 
      } 

       try 
       { 
        return this.Container.Resolve(serviceType); 
       } 
       catch (ResolutionFailedException) 
       { 
        return null; 
       } 
      } 

可能是我不清楚我的問題,請讓我知道。

回答

0

我更換

using System.Web.Mvc; 

using System.Web.Http; 

和它的工作。

相關問題