Skip to content

Calling a Controller at server side #7294

Discussion options

You must be logged in to vote

Instead calling endpoint, you can create a service LeaveRequestEmailSender with interface ILeaveRequestEmailSender, then you can call it from your endpoint. And also you can inject this interface in any of your class in the project. Endpoints has HttpContext and requires some pipelines like authorization etc. Don't call endpoints in the projects unless strict requirements.

public Result<ServiceResponse> SendEmail(LeaveRequestModel request, 
    [FromServices] ILeaveRequestEmailSender leaveRequestEmailSender)
{...

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by flashyjunior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants