我在单独的项目中有简单的 ApiController:
<Export("Custom", GetType(ApiController)),
PartCreationPolicy(CreationPolicy.NonShared)>
Public Class CustomController
Inherits ApiController
Public Function GetSomething() As HttpResponseMessage
Dim Result As New Something() With {
.Code = "Code",
.SomeField = "Something",
.SomeField2 = 5
}
Return Request.CreateResponse(System.Net.HttpStatusCode.OK, Result)
End Function
End Class
在谷歌搜索了一段时间后,我设法使用 IHttpControllerSelector 和 IHttpControllerActivator 的自定义实现来解析控制器。但现在得到错误:"No action was found on the controller 'Custom' that matches the name 'GetSomething'"
。意味着我必须实现 IHttpActionSelector 并且之后可能还有其他东西......这听起来非常复杂且不合逻辑,因为我没有尝试进行任何自定义处理。任何提示我哪里出错了?