Base solution for your next web application
Open Closed

Can't add new methods to API AccountController #1896


User avatar
0
amayorquin created

Hi,

I'm trying to add a new method to the AccountController in the API project but is not working, looks like the controller just allow one method, I created a different controller and is the same thing. If I rename the Authenticate method to anything else I am still can access the Authenticate method in postman, seems that is the default route and just allow one method. When I added a new method just throw an error but nothing is registered in the error log, can you help me, please. I don't know if I missing something. Thanks in advance


3 Answer(s)
  • User Avatar
    0
    andmattia created

    I think probably you need to pass token to your method

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Can you share your controller's code ?

  • User Avatar
    0
    amayorquin created

    Hi, thank you for you response.

    I just added a new dummy method in the api AccountController:

    [Route("api/Account/Register")]
            [HttpPost]
            public AjaxResponse Register()
            {
                return new AjaxResponse(true);
            }
    

    and just added the route in the Authenticate action:

    [Route("api/Account/Authenticate")]

    The Authenticate action is working, but the when I hit to Register action is calling the Authenticate action, even if I just call the api like this: <a class="postlink" href="http://localhost:6634/api/Account">http://localhost:6634/api/Account</a> is responding the Authenticate method

    Those are the only changes I made. I don't know if I have to configurate something else.

    Thanks in advance