Moved nullcheck to top to catch possible nullreference exceptions

This commit is contained in:
Dave de Moel
2021-07-15 10:48:39 +02:00
parent a5ee8566b8
commit 62352fc1a6

View File

@@ -27,10 +27,6 @@ namespace Umbraco.Extensions
/// </summary>
public static IUmbracoApplicationBuilder UseUmbraco(this IApplicationBuilder app)
{
IOptions<UmbracoPipelineOptions> startupOptions = app.ApplicationServices.GetRequiredService<IOptions<UmbracoPipelineOptions>>();
app.RunPrePipeline(startupOptions.Value);
// TODO: Should we do some checks like this to verify that the corresponding "Add" methods have been called for the
// corresponding "Use" methods?
// https://github.com/dotnet/aspnetcore/blob/b795ac3546eb3e2f47a01a64feb3020794ca33bb/src/Mvc/Mvc.Core/src/Builder/MvcApplicationBuilderExtensions.cs#L132
@@ -39,6 +35,9 @@ namespace Umbraco.Extensions
throw new ArgumentNullException(nameof(app));
}
IOptions<UmbracoPipelineOptions> startupOptions = app.ApplicationServices.GetRequiredService<IOptions<UmbracoPipelineOptions>>();
app.RunPrePipeline(startupOptions.Value);
app.UseUmbracoCore();
app.UseUmbracoRequestLogging();