Run code only once in app start RRS feed

  • Question

  • User477335199 posted

    Hi everyone

    In asp.net mvc 5  we have global.asax and we can use App_Start event for it.
    How I can implement it in .net core ?

    Is it possible ?

    Tuesday, April 6, 2021 12:53 PM


  • User1686398519 posted

    Hi PopSeka, 

    When the first request is received, ASP.NET will call the Application_Start method in the class of the Global.asax file before processing the request itself. Any logic that needs to be run when the ASP.NET MVC application starts can be added to this method.

     ASP.NET Core apps typically include a Program.cs file containing the entry point for the app. While it's possible to completely configure an ASP.NET Core app using the IHostBuilder, typically the bulk of this work is done in a Startup class.

    ASP.NET Core applications usually include a Program.cs file, which contains the entry point of the application. Although you can use IHostBuilder to fully configure an ASP.NET Core application, usually most of the work is done in the Startup class.

    • You register the interface in ConfigureServices and the host does the rest, calling the StartAsync method before the app starts up.

    App startup differences between ASP.NET MVC and ASP.NET Core

    Best Regards,


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 7, 2021 5:42 AM

All replies