2

I need to execute some logic after application startup in ASP Core app.
In ASP MVC it's performed in Application_Start() Global.asax method.
How am I supposed to do it in ASP Core (in respect with best practice) ?

1 Answer 1

4

you can use Configure method in Startup.cs

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    ....
    IMyEndpointService service = app.ApplicationServices.GetService<IMyEndpointService>();
    var result = service.ExecuteMyMethod();
    ....

}

but it also depends on what you are trying to achieve. If you provide more information you can get to the point answer.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.