Beispiel #1
0
        public override void BuildPipeline(RequestPipelineBuilder builder)
        {
            builder.Configure(StarterOrdering.AuthenticationMiddleware, app =>
            {
                // TODO: (core) Check whether it's ok to run authentication middleware before routing. We desperately need auth before any RouteValueTransformer.
                app.UseAuthentication();
            });

            builder.Configure(StarterOrdering.AfterRoutingMiddleware, app =>
            {
                app.UseAuthorization();
            });
        }
Beispiel #2
0
 public override void BuildPipeline(RequestPipelineBuilder builder)
 {
     // Run before bundling middleware
     builder.Configure(StarterOrdering.BeforeStaticFilesMiddleware - 1, app =>
     {
         app.UseMedia();
     });
 }
        public override void BuildPipeline(RequestPipelineBuilder builder)
        {
            builder.Configure(StarterOrdering.BeforeStaticFilesMiddleware, app =>
            {
                app.UseMiddleware <BundleMiddleware>();

                var bundles   = app.ApplicationServices.GetRequiredService <IBundleCollection>();
                var publisher = new BundlePublisher();
                publisher.RegisterBundles(builder.ApplicationContext, bundles);
            });

            builder.Configure(StarterOrdering.StaticFilesMiddleware, app =>
            {
                // TODO: (core) Set StaticFileOptions
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileProvider        = builder.ApplicationBuilder.ApplicationServices.GetRequiredService <IAssetFileProvider>(),
                    ContentTypeProvider = MimeTypes.ContentTypeProvider
                });
            });
        }
Beispiel #4
0
        public override void BuildPipeline(RequestPipelineBuilder builder)
        {
            var appContext = builder.ApplicationContext;

            builder.Configure(StarterOrdering.BeforeStaticFilesMiddleware, app =>
            {
                if (appContext.HostEnvironment.IsDevelopment() || appContext.AppConfiguration.UseDeveloperExceptionPage)
                {
                    app.UseDeveloperExceptionPage();
                }
                else
                {
                    app.UseExceptionHandler("/Error");
                    // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                    app.UseHsts();
                }

                app.UseStatusCodePagesWithReExecute("/Error/{0}");
            });

            builder.Configure(StarterOrdering.FirstMiddleware, app =>
            {
                // TODO: (core) Find decent ordering for MiniProfiler
                app.UseMiniProfiler();
            });

            builder.Configure(StarterOrdering.RoutingMiddleware, app =>
            {
                app.UseRouting();
            });

            builder.Configure(StarterOrdering.AfterRoutingMiddleware, app =>
            {
                // TODO: (core) Use Swagger
                // TODO: (core) Use Response compression
            });

            builder.Configure(StarterOrdering.EarlyMiddleware, app =>
            {
                // TODO: (core) Configure session
                app.UseSession();

                if (appContext.IsInstalled)
                {
                    app.UseUrlPolicy();
                    app.UseRequestCulture();
                    app.UseMiddleware <SerilogHttpContextMiddleware>();
                }
            });

            builder.Configure(StarterOrdering.DefaultMiddleware, app =>
            {
                // TODO: (core) Configure cookie policy
                app.UseCookiePolicy();
            });
        }
Beispiel #5
0
        public override void BuildPipeline(RequestPipelineBuilder builder)
        {
            builder.Configure(StarterOrdering.EarlyMiddleware, app =>
            {
                app.Use(async(context, next) =>
                {
                    var routeValues = context.GetRouteData().Values;

                    if (!routeValues.GetControllerName().EqualsNoCase(InstallControllerName))
                    {
                        context.Response.Redirect(context.Request.PathBase.Value + "/" + InstallControllerName);
                        return;
                    }

                    await next();
                });
            });
        }