✅ [SOLVED] Multiple functions in same controller? ASP.NET Core API

Hello, I would like to have multiple functions in the same api controller with different routes (eg. "api/[controller]/[function], how would I do that? This is my structure
namespace xyz.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class LoginController : ControllerBase
{
[HttpPost(Name = "functionName")]
public someData functionName()
{
// I would want this to have the route "api/Login/functionName", how do I add the "functionName" to it?
}
}
}
namespace xyz.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class LoginController : ControllerBase
{
[HttpPost(Name = "functionName")]
public someData functionName()
{
// I would want this to have the route "api/Login/functionName", how do I add the "functionName" to it?
}
}
}
4 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
1FriendlyDoge
1FriendlyDogeOP2y ago
Wow, thanks a lot, solved the issue :D
cap5lut
cap5lut2y ago
@1FriendlyDoge, if u use just [HttpPost] it would automatically map to the name of the method. also use the correct command to $close the thread please:
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server