public static void UseAbp(this IAppBuilder app, [CanBeNull] Action <AbpOwinOptions> optionsAction)
        {
            ThreadCultureSanitizer.Sanitize();

            var options = new AbpOwinOptions
            {
                UseEmbeddedFiles = HttpContext.Current?.Server != null
            };

            optionsAction?.Invoke(options);

            if (options.UseEmbeddedFiles)
            {
                if (HttpContext.Current?.Server == null)
                {
                    throw new AbpInitializationException("Can not enable UseEmbeddedFiles for OWIN since HttpContext.Current is null! If you are using ASP.NET Core, serve embedded resources through ASP.NET Core middleware instead of OWIN. See http://www.aspnetboilerplate.com/Pages/Documents/Embedded-Resource-Files#aspnet-core-configuration");
                }

                app.UseStaticFiles(new StaticFileOptions
                {
                    FileSystem = new AbpOwinEmbeddedResourceFileSystem(
                        IocManager.Instance.Resolve <IEmbeddedResourceManager>(),
                        IocManager.Instance.Resolve <IWebEmbeddedResourcesConfiguration>(),
                        HttpContext.Current.Server.MapPath("~/")
                        )
                });
            }
        }
Esempio n. 2
0
        public static void UseAbp(this IAppBuilder app, [CanBeNull] Action <AbpOwinOptions> optionsAction)
        {
            ThreadCultureSanitizer.Sanitize();

            var options = new AbpOwinOptions();

            optionsAction?.Invoke(options);

            if (options.UseEmbeddedFiles)
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    FileSystem = new AbpOwinEmbeddedResourceFileSystem(
                        IocManager.Instance.Resolve <IEmbeddedResourceManager>(),
                        IocManager.Instance.Resolve <IWebEmbeddedResourcesConfiguration>()
                        )
                });
            }
        }