Пример #1
0
        public void Configure(IApplicationBuilder aspNetCoreApp, OwinAppStartup owinAppStartup, IEnumerable <IAspNetCoreMiddlewareConfiguration> aspNetCoreMiddlewares)
        {
            if (string.IsNullOrEmpty(WebHostEnvironment.WebRootPath))
            {
                WebHostEnvironment.WebRootPath = _pathProvider.GetStaticFilesFolderPath();
            }

            if (Directory.Exists(WebHostEnvironment.WebRootPath) && (WebHostEnvironment.WebRootFileProvider == null || WebHostEnvironment.WebRootFileProvider is NullFileProvider))
            {
                WebHostEnvironment.WebRootFileProvider = new PhysicalFileProvider(WebHostEnvironment.WebRootPath);
            }

            ConfigureBitAspNetCoreApp(aspNetCoreApp, owinAppStartup, aspNetCoreMiddlewares);
        }
Пример #2
0
        public void Configure(IApplicationBuilder aspNetCoreApp, OwinAppStartup owinAppStartup, IEnumerable <IAspNetCoreMiddlewareConfiguration> aspNetCoreMiddlewares, IServiceProvider serviceProvider, IPathProvider pathProvider)
        {
            IWebHostEnvironment webHostEnvironment = serviceProvider.GetService <IWebHostEnvironment>();

            if (webHostEnvironment != null)
            {
                if (string.IsNullOrEmpty(webHostEnvironment.WebRootPath))
                {
                    webHostEnvironment.WebRootPath = pathProvider.GetStaticFilesFolderPath();
                }

                if (Directory.Exists(webHostEnvironment.WebRootPath) && (webHostEnvironment.WebRootFileProvider == null || webHostEnvironment.WebRootFileProvider is NullFileProvider))
                {
                    webHostEnvironment.WebRootFileProvider = new PhysicalFileProvider(webHostEnvironment.WebRootPath);
                }
            }

            ConfigureBitAspNetCoreApp(aspNetCoreApp, owinAppStartup, aspNetCoreMiddlewares);
        }
Пример #3
0
        public void ConfigureBitAspNetCoreApp(IApplicationBuilder aspNetCoreApp, OwinAppStartup owinAppStartup, IEnumerable <IAspNetCoreMiddlewareConfiguration> aspNetCoreMiddlewares)
        {
            if (owinAppStartup == null)
            {
                throw new ArgumentNullException(nameof(owinAppStartup));
            }

            aspNetCoreMiddlewares
            .Where(m => m.MiddlewarePosition == MiddlewarePosition.BeforeOwinMiddlewares)
            .ToList()
            .ForEach(aspNetCoreMiddleware => aspNetCoreMiddleware.Configure(aspNetCoreApp));

            ConfigureMiddlewares(aspNetCoreApp);

            aspNetCoreApp.UseOwinApp(owinAppStartup.Configuration);

            aspNetCoreMiddlewares
            .Where(m => m.MiddlewarePosition == MiddlewarePosition.AfterOwinMiddlewares)
            .ToList()
            .ForEach(aspNetCoreMiddleware => aspNetCoreMiddleware.Configure(aspNetCoreApp));
        }