浏览器访问ABP 的api,会报错

Request verb is GET. It should be Post(ABP使用api访问错误)

需要改下web项目下配置文件的customErrors属性,<customErrors mode="On" />改为<customErrors mode="RemoteOnly" />即可显示错误信息

 Request verb is GET. It should be Post(ABP使用api访问错误)

这个地方看了很多帖子都没有写到,难道他们都没遇到吗?

在一片外文技术帖子找到解决方法,这里记录下 

WithVerb 方法

Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
    .For<ITaskAppService>("tasksystem/task")
    .ForMethod("GetTasks").WithVerb(HttpVerb.Get)
    .Build();

http属性标识(我用这个)

public interface ITaskAppService : IApplicationService
    {
        [HttpGet]
        Task<ListResultDto<TaskListDto>> GetTaskList();

        //[HttpGet]
        ListResultDto<TaskListDto> GetTasks();
    }

HttpGet需要Application项目在NuGet管理器中添加Microsoft.AspNet.WebApi.Core包

重新生成访问即可

 

相关文章:

  • 2022-12-23
  • 2021-07-07
  • 2021-09-06
  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-05
  • 2021-05-28
  • 2021-05-31
  • 2021-06-23
  • 2021-11-03
  • 2022-01-16
相关资源
相似解决方案