在查询递归实体查找时,我收到以下错误。
错误:
{" message":"发生了错误。"," exceptionMessage":"有针对GetCategories定义的操作api控制器app / category但具有不同的HTTP动词。请求动词是GET。它应该是Post"," exceptionType":" System.Web.HttpException"," stackTrace":" at Abp.WebApi.Controllers.Dynamic.Selectors.AbpApiControllerActionSelector.GetActionDescriptorByActionName(HttpControllerContext controllerContext,DynamicApiControllerInfo controllerInfo,String actionName)\ r \ n at Abp.WebApi.Controllers.Dynamic.Selectors.AbpApiControllerActionSelector.SelectAction(HttpControllerContext controllerContext)\ r \ n在Castle.Proxies.DynamicApiController
1Proxy_5.ExecuteAsync_callback(HttpControllerContext controllerContext, CancellationToken cancellationToken)\r\n at Castle.Proxies.Invocations.ApiController_ExecuteAsync_5.InvokeMethodOnTarget()\r\n at Castle.DynamicProxy.AbstractInvocation.Proceed()\r\n at Abp.WebApi.Controllers.Dynamic.Interceptors.AbpDynamicApiControllerInterceptor
处的System.Web.Http.ApiController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)\ r \ n中1.在Castle.DynamicProxy.AbstractInvocation中接受(IInvocation调用)\ r \ n。继续()\ r \ n在Castle.Proxies.DynamicApiController`1Proxy_5.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)\ r \ n在System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()&#34;} < / em>的
仅在添加具有ParentId
模型
[Table("Categories")]
public class Category : FullAuditedEntity
{
[Required]
public string Name { get; set; }
[Required]
public string SharepointMapping { get; set; }
public int? ParentId { get; set; }
public Category Parent { get; set; }
public List<Category> Children { get; set; }
}
CategoryAppService
public ListResultDto<CategoryListDto> GetCategories(GetCategoriesInput input)
{
var categories = _categoryRepository
.GetAll()
.WhereIf(
!input.Filter.IsNullOrEmpty(),
p => p.Name.Contains(input.Filter)
)
.OrderBy(p => p.Name)
.ToList();
return new ListResultDto<CategoryListDto>(categories.MapTo<List<CategoryListDto>>());
}
CategoryListDto
[AutoMapFrom(typeof(Category))]
public class CategoryListDto : FullAuditedEntityDto
{
public string Name { get; set; }
public string SharepointMapping { get; set; }
public int? ParentId { get; set; }
public virtual Category Parent { get; set; }
}
答案 0 :(得分:1)
所有WebApi方法的默认http-verb为 POST 。 使用POST发出请求。
如果你不喜欢这个解决方案,你可以使用传统的动词。使用常规谓词,它查找方法名称前缀并匹配相关的http-verb。
您可以使用WithConventionalVerbs方法,如下所示:
Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
.ForAll<IApplicationService>(Assembly.GetAssembly(typeof(SimpleTaskSystemApplicationModule)), "tasksystem")
.WithConventionalVerbs()
.Build();
了解更多信息: https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API