Base solution for your next web application
Open Closed

Http verbs don't working #7578


User avatar
0
digitalcontrol created

I installed Microsoft.AspNet.WebApi.Core, and in interface of AppService I put [HttpPost] to change method from Get to Post, but it didn't work. Method is still Get.


5 Answer(s)
  • User Avatar
    0
    alper created
    Support Team

    hi,

    you need to add the verbs to the interface https://aspnetboilerplate.com/Pages/Documents/Dynamic-Web-API#withverb-method

    public interface ITaskAppService : IApplicationService
    {
        [HttpGet]
        GetTasksOutput GetTasks(GetTasksInput input);
    
        [HttpPut]
        void UpdateTask(UpdateTaskInput input);
    
        [HttpPost]
        void CreateTask(CreateTaskInput input);
    }
    
    
  • User Avatar
    0
    digitalcontrol created

    I did that but only for one method. Should I add to every method?

  • User Avatar
    0
    maliming created
    Support Team

    hi digitalcontrol

    If you need to modify it, you need to add for each method.

  • User Avatar
    0
    digitalcontrol created

    I added for each method in AppService interface Http atribute, still the same.

  • User Avatar
    0
    maliming created
    Support Team

    @digitalcontrol Is your application Net Core?

    see:https://github.com/aspnetzero/aspnet-zero-core/issues/2620