public void EmbeddedDirectoryBrowserFileSystemConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions()
     {
         FileSystem = new EmbeddedResourceFileSystem(Assembly.GetExecutingAssembly().GetName().Name)
     });
 }
 internal void CustomFileSystemConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions()
     {
         FileSystem = new MyFileSystem()
     });
 }
Esempio n. 3
0
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem  = new PhysicalFileSystem(@".\defaults"),
            });

            // Only serve files requested by name.
            app.UseStaticFiles("/files");

            // Turns on static files, directory browsing, and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath             = new PathString("/public"),
                EnableDirectoryBrowsing = true,
            });

            // Browse the root of your application (but do not serve the files).
            // NOTE: Avoid serving static files from the root of your application or bin folder,
            // it allows people to download your application binaries, config files, etc..
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/src"),
                FileSystem  = new PhysicalFileSystem(@""),
            });

            // Anything not handled will land at the welcome page.
            app.UseWelcomePage();
        }
 public void DirectoryBrowserCustomFormatterConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions()
     {
         Formatter = new MyDirectoryInfoFormatter()
     });
 }
Esempio n. 5
0
        public void Configuration(IAppBuilder app)
        {
            /* // Note: Enable only for debugging. This slows down the perf tests.
            app.Use((context, next) =>
            {
                var req = context.Request;
                context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
                return next();
            });*/

            app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 20 });
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.Use<CanonicalRequestPatterns>();

            app.UseStaticFiles(new StaticFileOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem = new PhysicalFileSystem("public")
            });
            app.UseStageMarker(PipelineStage.MapHandler);

            FileServerOptions options = new FileServerOptions();
            options.EnableDirectoryBrowsing = true;
            options.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseWelcomePage("/Welcome");
        }
Esempio n. 6
0
        public void Configuration(IAppBuilder app)
        {
            app.UseErrorPage(new ErrorPageOptions()
            {
                ShowSourceCode       = true,
                ShowEnvironment      = true,
                ShowExceptionDetails = true,
                ShowQuery            = true
            });

            app.UseCors(CorsOptions.AllowAll);

            var config = GetWebApiConfig();

            app.UseWebApi(config);

            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem  = new PhysicalFileSystem(@".\www")
            });

            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/download"),
                FileSystem  = new PhysicalFileSystem(@".\www\download"),
            });
        }
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif
            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(@".\defaults"),
            });

            // Only serve files requested by name.
            app.UseStaticFiles("/files");

            // Turns on static files, directory browsing, and default files.
            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = new PathString("/public"),
                EnableDirectoryBrowsing = true,
            });

            // Browse the root of your application (but do not serve the files).
            // NOTE: Avoid serving static files from the root of your application or bin folder,
            // it allows people to download your application binaries, config files, etc..
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/src"),
                FileSystem = new PhysicalFileSystem(@""),
            });

            // Anything not handled will land at the welcome page.
            app.UseWelcomePage();
        }
Esempio n. 8
0
 internal void DirectoryMiddlewareMappedToDifferentDirectoryConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions()
     {
         FileSystem = new PhysicalFileSystem(@"RequirementFiles\Dir1")
     });
 }
Esempio n. 9
0
 /// <summary>
 /// Configure the OwinApp
 /// </summary>
 /// <param name="app"></param>
 public void Configuration(IAppBuilder app)
 {
     app.UseErrorPage();
     //app.UseCors(CorsOptions.AllowAll);
     app.UseDirectoryBrowser();
     app.UseRazor(InitRoutes);
     app.UseWebApi(typeof(PeopleController).Assembly);
 }
Esempio n. 10
0
        internal void DirectoryCustomRequestPathToPhysicalPathMappingConfiguration(IAppBuilder app)
        {
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/customrequestPath"),
                FileSystem  = new PhysicalFileSystem(@"RequirementFiles\Dir1")
            });

            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/customrequestFullPath"),
                FileSystem  = new PhysicalFileSystem(Path.Combine(Environment.CurrentDirectory, @"RequirementFiles\Dir2"))
            });

            var localAbsolutePath = Path.Combine(Environment.CurrentDirectory, @"RequirementFiles\Dir3");
            var uncPath           = Path.Combine("\\\\", Environment.MachineName, localAbsolutePath.Replace(':', '$'));

            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/customrequestUNCPath"),
                FileSystem  = new PhysicalFileSystem(uncPath)
            });
        }
Esempio n. 11
0
        public void Configuration(IAppBuilder app)
        {
            /* // Note: Enable only for debugging. This slows down the perf tests.
             * app.Use((context, next) =>
             * {
             *  var req = context.Request;
             *  context.TraceOutput.WriteLine("{0} {1}{2} {3}", req.Method, req.PathBase, req.Path, req.QueryString);
             *  return next();
             * });*/

            app.UseErrorPage(new ErrorPageOptions {
                SourceCodeLineCount = 20
            });
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.Use <CanonicalRequestPatterns>();

            app.UseStaticFiles(new StaticFileOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem  = new PhysicalFileSystem("public")
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/static"),
                FileSystem  = new PhysicalFileSystem("public")
            });
            app.UseStageMarker(PipelineStage.MapHandler);

            app.Map("/static-compression", map => map
                    .UseStaticCompression()
                    .UseFileServer(new FileServerOptions()
            {
                EnableDirectoryBrowsing = true,
                FileSystem = new PhysicalFileSystem("Public")
            }));

            FileServerOptions options = new FileServerOptions();

            options.EnableDirectoryBrowsing = true;
            options.StaticFileOptions.ServeUnknownFileTypes = true;

            app.Map("/danger", map => map
                    .UseStaticCompression()
                    .UseFileServer(options));

            app.UseWelcomePage("/Welcome");
        }
Esempio n. 12
0
        public void Configuration(IAppBuilder app)
        {
            var fileSystem = new PhysicalFileSystem(this.serverConfig.RootFolder);

            if (this.serverConfig.AllowDirectoryBrowsing)
            {
                app.UseDirectoryBrowser(new DirectoryBrowserOptions()
                    {
                        FileSystem = fileSystem
                    });
            }

            app.UseStaticFiles(new StaticFileOptions()
                {
                    FileSystem = fileSystem,
                    ServeUnknownFileTypes = true
                });
        }
        public static IAppBuilder UseFileServer(this IAppBuilder builder, FileServerOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            builder = builder.UseDefaultFiles(options.DefaultFilesOptions);

            if (options.EnableDirectoryBrowsing)
            {
                builder = builder.UseDirectoryBrowser(options.DirectoryBrowserOptions);
            }

            return(builder
                   .UseSendFileFallback()
                   .UseStaticFiles(options.StaticFileOptions));
        }
Esempio n. 14
0
        private void ConfigureUserSpace(IAppBuilder appBuilder)
        {
            var appConfig = ObjectFactory.GetProvider<IAppConfigProvider>().AppConfig;
            var fileSystem = new PhysicalFileSystem(appConfig.WebRoot);

            appBuilder.Use(typeof(RedirectUrl));
            appBuilder.UseDirectoryBrowser(new DirectoryBrowserOptions
            {
                RequestPath = new PathString(""),
                FileSystem = fileSystem
            });

            appBuilder.UseStaticFiles(new StaticFileOptions
            {
                RequestPath = new PathString(""),
                FileSystem = fileSystem,
                ServeUnknownFileTypes = true
            });
        }
Esempio n. 15
0
        private void ConfigureUserSpace(IAppBuilder appBuilder)
        {
            var appConfig  = ObjectFactory.GetProvider <IAppConfigProvider>().AppConfig;
            var fileSystem = new PhysicalFileSystem(appConfig.WebRoot);

            appBuilder.Use(typeof(RedirectUrl));
            appBuilder.UseDirectoryBrowser(new DirectoryBrowserOptions
            {
                RequestPath = new PathString(""),
                FileSystem  = fileSystem
            });

            appBuilder.UseStaticFiles(new StaticFileOptions
            {
                RequestPath           = new PathString(""),
                FileSystem            = fileSystem,
                ServeUnknownFileTypes = true
            });
        }
Esempio n. 16
0
        public void DirectoryCustomRequestPathToPhysicalPathMappingConfiguration(IAppBuilder app)
        {
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/customrequestPath"),
                FileSystem = new PhysicalFileSystem(@"RequirementFiles\Dir1")
            });

            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/customrequestFullPath"),
                FileSystem = new PhysicalFileSystem(Path.Combine(Environment.CurrentDirectory, @"RequirementFiles\Dir2"))
            });

            var localAbsolutePath = Path.Combine(Environment.CurrentDirectory, @"RequirementFiles\Dir3");
            var uncPath = Path.Combine("\\\\", Environment.MachineName, localAbsolutePath.Replace(':', '$'));
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/customrequestUNCPath"),
                FileSystem = new PhysicalFileSystem(uncPath)
            });
        }
Esempio n. 17
0
 public void Configuration(IAppBuilder builder)
 {
     builder.UseDirectoryBrowser(@"c:\");
 }
Esempio n. 18
0
 public void EmbeddedDirectoryBrowserFileSystemConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileSystem = new EmbeddedResourceFileSystem(Assembly.GetExecutingAssembly().GetName().Name) });
 }
Esempio n. 19
0
 public void DirectoryBrowserDefaultsConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser();
 }
Esempio n. 20
0
 public void DirectoryMiddlewareMappedToDifferentDirectoryConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileSystem = new PhysicalFileSystem(@"RequirementFiles\Dir1") });
 }
Esempio n. 21
0
 /// <summary>
 /// Enable directory browsing on the given path for the given directory
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="path">The request path</param>
 /// <param name="directory">The physical directory</param>
 /// <returns></returns>
 public static IAppBuilder UseDirectoryBrowser(this IAppBuilder builder, string path, string directory)
 {
     return(builder.UseDirectoryBrowser(new DirectoryBrowserOptions().WithRequestPath(path).WithPhysicalPath(directory)));
 }
Esempio n. 22
0
 public void DirectoryBrowser(IAppBuilder app)
 {
     app.Use((context, next) => { context.Response.Headers["PassedThroughOWIN"] = "True"; return next(); });
     app.UseDirectoryBrowser();
     app.Run(context => { context.Response.StatusCode = 402; return context.Response.WriteAsync("Fell Through"); });
 }
Esempio n. 23
0
 public void CustomFileSystemConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions() { FileSystem = new MyFileSystem() });
 }
 public void DirectoryBrowserCustomFormatterConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser(new DirectoryBrowserOptions() { Formatter = new MyDirectoryInfoFormatter() });
 }
Esempio n. 25
0
 /// <summary>
 /// Enable directory browsing on the current path for the current directory
 /// </summary>
 /// <param name="builder"></param>
 /// <returns></returns>
 public static IAppBuilder UseDirectoryBrowser(this IAppBuilder builder)
 {
     return(builder.UseDirectoryBrowser(new DirectoryBrowserOptions()));
 }
Esempio n. 26
0
 public void DirectoryBrowser(IAppBuilder app)
 {
     app.Use((context, next) => { context.Response.Headers["PassedThroughOWIN"] = "True"; return(next()); });
     app.UseDirectoryBrowser();
     app.Run(context => { context.Response.StatusCode = 402; return(context.Response.WriteAsync("Fell Through")); });
 }
Esempio n. 27
0
 internal void DirectoryBrowserDefaultsConfiguration(IAppBuilder app)
 {
     app.UseDirectoryBrowser();
 }
 public void Configuration(IAppBuilder builder)
 {
     builder.UseDirectoryBrowser(@"c:\");
 }
Esempio n. 29
0
        private static void ConfigureStaticFileServer(IAppBuilder app)
        {
            #if DEBUG
            app.UseErrorPage();
            #endif
            // Remap '/' to '.\defaults\'.
            // Turns on static files and default files.
            var integrityUiPath = @"..\..\..\Integrity";

            string currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
            integrityUiPath = Path.Combine(currentDirectory, integrityUiPath);
            integrityUiPath = Path.GetFullPath((new Uri(integrityUiPath)).LocalPath);
            if (!Directory.Exists(integrityUiPath))
            {
                throw new Exception(String.Format("Directory {0} does not exist", integrityUiPath));
            }
            var options = new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(integrityUiPath)
            };
            //options.StaticFileOptions.ContentTypeProvider = new CustomContentTypeProvider();
            app.UseFileServer(options);

            //var hubConfiguration = new HubConfiguration();
            //hubConfiguration.EnableDetailedErrors = true;
            //app.MapSignalR(hubConfiguration);

            // Browse the root of your application (but do not serve the files).
            // NOTE: Avoid serving static files from the root of your application or bin folder,
            // it allows people to download your application binaries, config files, etc..
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                RequestPath = new PathString("/src"),
                FileSystem = new PhysicalFileSystem(@""),
            });
        }