using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Umbraco.Cms.Core.DependencyInjection; using Umbraco.Extensions; namespace Umbraco.Cms.Web.UI.NetCore { public class Startup { private readonly IWebHostEnvironment _env; private readonly IConfiguration _config; /// /// Initializes a new instance of the class. /// /// The Web Host Environment /// The Configuration /// /// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337 /// public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config) { _env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment)); _config = config ?? throw new ArgumentNullException(nameof(config)); } /// /// Configures the services /// /// /// This method gets called by the runtime. Use this method to add services to the container. /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 /// public void ConfigureServices(IServiceCollection services) { #pragma warning disable IDE0022 // Use expression body for methods services.AddUmbraco(_env, _config) .AddBackOffice() .AddWebsite() .AddComposers() .Build(); #pragma warning restore IDE0022 // Use expression body for methods } /// /// Configures the application /// public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseUmbraco() .WithMiddleware(u => { u.WithBackOffice(); u.WithWebsite(); }) .WithEndpoints(u => { u.UseInstallerEndpoints(); u.UseBackOfficeEndpoints(); u.UseWebsiteEndpoints(); }); } } }