public static void Main(string[] args)
        {
            CloudRoleTelemetryInitializer.SetRoleName("CustomersMVC");

            // WebHost.CreateDefaultBuilder is a convenient helper method that
            // will configure an IWebHostBuilder with common configuration
            // (Kestrel, typical logging and config settings, etc.).
            // It is still possible to modify the IWebHostBuilder after it has
            // been created with CreateDefaultBuiler, as shown here.
            var host = WebHost
                       .CreateDefaultBuilder()

                       // Enables automatic per-request diagnostics in AppInsights
                       .UseApplicationInsights()
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }
Example #2
0
        public static void Main(string[] args)
        {
            // Sets the service's name in AppInsights telemetry
            CloudRoleTelemetryInitializer.SetRoleName("CustomersAPI");

            var host = new WebHostBuilder()

                       // Enables automatic per-request diagnostics in AppInsights
                       .UseApplicationInsights()

                       // Selects Kestrel as the web host (as opposed to Http.Sys)
                       .UseKestrel()

                       // Dependency Injection: Services can be registered with the ASP.NET Core DI container at IWebHost build-time
                       // by calling ConfigureServices on the WebHostBuilder.
                       //
                       // Dependency Injection: This is an easy way of injecting services that wouldn't otherwise be available in
                       // the web application's Startup class (for example, web apps running in a Service Fabric
                       // application could have their service context injected here).
                       //
                       // Localization: Here we are adding a singleton instance of the ResourceManager into the ServicesCollection for the
                       //               CustomersController. The naming convention for the resource files for the CustomersController follows
                       //               the path pattern by locating the resources in Resources/Controllers/CustomersController.<language>.resx.
                       .ConfigureServices(serviceCollection =>
            {
                serviceCollection.AddSingleton(new ResourceManager("CustomersAPI.Resources.Controllers.CustomersController",
                                                                   typeof(Startup).GetTypeInfo().Assembly));
            })
                       .ConfigureAppConfiguration(ConfigureAppConfiguration)
                       .ConfigureLogging(ConfigureLogging)
                       .UseUrls("http://+:5000") // Informs Kestrel which ports to listen on; use Kestrel options/listeners for more control
                       .UseContentRoot(Directory.GetCurrentDirectory())
                       .UseIISIntegration()
                       .UseStartup <Startup>()
                       .Build();

            host.Run();
        }