title: Differences between Program.cs and App.razor
body: <p>What's the differences bettwen <code>Program.cs</code> and <code>App.razor</code> in Blazor (Server Side)? I tested and i know that the <code>App.razor</code> is executed after <code>Program.cs</code>, when i need execute a method before App start i put the method inside <code>CreateHostBuilder</code>.
  When should i use <code>App.razor</code> and <code>Program.cs</code>? What can i do in <code>Program.cs</code> and not in <code>App.razor</code>?(and viceverse) What's the adventages?</p>
  <p><em>Program.cs</em></p>
  <pre><code>public static void Main(string[] args)
      {
          CreateHostBuilder(args).Build().Run();
      }
  
      public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
          Host.CreateDefaultBuilder(args)
              .ConfigureWebHostDefaults(async webBuilder =&gt;
              {
                  webBuilder.UseStartup&lt;Startup&gt;();
                  await MethodAsync();
              });
  
      private static async Task MethodAsync()
      {
          //body
      }
  </code></pre>
  <p><em>App.razor</em></p>
  <pre><code>@code
  {
    protected override void OnInitialized()
    {
      await MethodAsync();
    }
    private static async Task MethodAsync()
    {
       //body
    }
  }
  </code></pre>
  <p><strong>NOTE:</strong> IM REFERING AT THE C# CODE AND HOW IT WORKS</p>