public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            appBuilder.UseWebApi(config);

            var appFolder = Path.Combine(Directory.GetParent(AppDomain.CurrentDomain.BaseDirectory).Parent.Parent.FullName, "Webportal");

            appBuilder.UseFileServer(new Microsoft.Owin.StaticFiles.FileServerOptions
            {
                RequestPath = new PathString(WebPortalUrl),
                FileSystem = new PhysicalFileSystem(appFolder),
                EnableDirectoryBrowsing = true

            });

            appBuilder.Map(PathString.Empty, a => a.Use<PortalRedirectionMiddelware>(WebPortalUrl));
            appBuilder.Use<AdminMiddleware>();
        }
        public void Configuration(IAppBuilder app)
        {
            var appOptions = new FileServerOptions
            {
                RequestPath = new PathString("/app"),
                FileSystem = new PhysicalFileSystem("app"),
                EnableDefaultFiles = true
            };
            appOptions.DefaultFilesOptions.DefaultFileNames.Add("index.html");
            appOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseFileServer(appOptions);

            var libsOptions = new FileServerOptions
            {
                RequestPath = new PathString("/libs"),
                FileSystem = new PhysicalFileSystem("libs")
            };
            libsOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            app.UseFileServer(libsOptions);

            app.UseErrorPage();
            app.MapSignalR();
        }
        // Invoked once at startup to configure your application.
        public void Configuration(IAppBuilder builder)
        {
            // Allow directory browsing from a specific dir.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/browse");
                options.WithPhysicalPath("public");
                options.WithDirectoryBrowsing();
            });

            // Allow file access to a specific dir.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/non-browse");
                options.WithPhysicalPath("protected");
            });

            // Serve default files out of the specified directory for the root url.
            builder.UseFileServer(options =>
            {
                options.WithRequestPath("/");
                options.WithPhysicalPath("protected");
                // options.WithDefaultFileNames(new[] { "index.html" }); // Already included by default.
            });

            builder.UseType<ServeSpecificPage>(@"protected\CustomErrorPage.html");
        }
        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();
        }
Example #5
0
        /// <summary>Addes the Swagger generator and Swagger UI to the OWIN pipeline.</summary>
        /// <param name="app">The app.</param>
        /// <param name="controllerTypes">The Web API controller types.</param>
        /// <param name="configure">Configure the Swagger settings.</param>
        /// <param name="schemaGenerator">The schema generator.</param>
        /// <returns>The app builder.</returns>
        public static IAppBuilder UseSwaggerReDoc(
            this IAppBuilder app,
            IEnumerable <Type> controllerTypes,
            Action <SwaggerReDocSettings <WebApiToSwaggerGeneratorSettings> > configure = null,
            SwaggerJsonSchemaGenerator schemaGenerator = null)
        {
            var settings = new SwaggerReDocSettings <WebApiToSwaggerGeneratorSettings>();

            configure?.Invoke(settings);

            if (controllerTypes != null)
            {
                app.Use <SwaggerDocumentMiddleware>(settings.ActualSwaggerDocumentPath, controllerTypes, settings, schemaGenerator ?? new SwaggerJsonSchemaGenerator(settings.GeneratorSettings));
            }

            app.Use <RedirectToIndexMiddleware>(settings.ActualSwaggerUiPath, settings.ActualSwaggerDocumentPath, settings.TransformToExternalPath);
            app.Use <SwaggerUiIndexMiddleware <WebApiToSwaggerGeneratorSettings> >(settings.ActualSwaggerUiPath + "/index.html", settings, "NSwag.AspNet.Owin.ReDoc.index.html");
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(settings.ActualSwaggerUiPath),
                FileSystem  = new EmbeddedResourceFileSystem(typeof(SwaggerExtensions).Assembly, "NSwag.AspNet.Owin.ReDoc")
            });
            app.UseStageMarker(PipelineStage.MapHandler);
            return(app);
        }
Example #6
0
        public static void ConfigureIIS(IAppBuilder app)
        {
            Bootstrapper.StartApp();

            var handler = DependencyContainer.Current.Resolve<IOwinHandler>();

            app.Map("/api", builder =>
            {
                builder.Run(handler.Invoke);
            });

            app.UseFileServer(new FileServerOptions
            {
                EnableDefaultFiles = true,
                DefaultFilesOptions = {DefaultFileNames = {"index.html"}},
                FileSystem = new PhysicalFileSystem("app"),
                StaticFileOptions =
                {
                    ContentTypeProvider = new FileExtensionContentTypeProvider(
                        new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
                        {
                            {".css", "text/css"},
                            {".html", "text/html"},
                            {".js", "application/javascript"}
                        })
                }
            });

            app.Use<OwinSpaMiddleware>("index.html");
        }
Example #7
0
        // This code configures Web API. The OlStartup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {/*
          * string str = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"webdir");
          * appBuilder.UseStaticFiles(str);
          */
            var root = AppDomain.CurrentDomain.BaseDirectory;
            var fileServerOptions = new FileServerOptions()
            {
                EnableDefaultFiles      = true,
                EnableDirectoryBrowsing = true,
                FileSystem = new PhysicalFileSystem(@"C:\Partcom\VoiceloggerSip\Client")
            };

            appBuilder.UseFileServer(fileServerOptions);


            appBuilder.UseCors(CorsOptions.AllowAll);
            appBuilder.MapSignalR();

            /*
             * // Configure Web API for self-host.
             * HttpConfiguration config = new HttpConfiguration();
             * config.Routes.MapHttpRoute(
             *  name: "DefaultApi",
             *  routeTemplate: "api/{controller}/{id}",
             *  defaults: new { id = RouteParameter.Optional }
             * );
             *
             * appBuilder.UseWebApi(config);
             */
        }
Example #8
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"),
            });
        }
Example #9
0
        public void Configuration(IAppBuilder app)
        {
            //app.UseWelcomePage("/");

            var config = new HttpConfiguration();

            // Web API
            ApiStartup.Register(config);
            app.UseWebApi(config);

            // JSON payload by default.
            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");

            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

            app.MapSignalR();

            // File Server (Use public folder from SPA project.)
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem  = new PhysicalFileSystem("../../../../../../ngOwinSpa/public")
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #10
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            WebApiConfig.Register(httpConfiguration);

            httpConfiguration.Routes.MapHttpRoute(
                name: "Html",
                routeTemplate: "view*",
                defaults: new { view = "index.html", controller = "default" }
                );

            app.UseWebApi(httpConfiguration);

            if (!app.Properties.ContainsKey("Test"))
            {
                // Make ./public the default root of the static files in our Web Application.
                const string root = ".";
                app.UseFileServer(new FileServerOptions
                {
                    RequestPath             = new PathString(string.Empty),
                    FileSystem              = new PhysicalFileSystem(root),
                    EnableDirectoryBrowsing = true,
                });
            }

            app.UseStageMarker(PipelineStage.MapHandler);
        }
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            var options = new FileServerOptions()
            {
                RequestPath = new PathString(""),
                FileSystem = new PhysicalFileSystem("client"),
                EnableDefaultFiles = true,
                EnableDirectoryBrowsing = true
            };
            options.DefaultFilesOptions.DefaultFileNames.Add("index.html");
            options.StaticFileOptions.ServeUnknownFileTypes = true;

            appBuilder.MapSignalR();
            appBuilder.UseFileServer(options);



            var config = new HttpConfiguration();
            ConfigureDependancyResolver(config);

            config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{employeeId}");

            appBuilder.UseCors(CorsOptions.AllowAll);
            appBuilder.UseWebApi(config);
        }
Example #12
0
        public void Configuration(IAppBuilder appBuilder)
        {
            appBuilder.Use <ExceptionsMiddleware>();

            var config = new HttpConfiguration();

            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
            config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
            config.MapHttpAttributeRoutes(new InheritedAttributesRouteProvider());
            config.Services.Replace(typeof(IExceptionHandler), new PassThroughExceptionsHandler());

            appBuilder.UseWebApi(config);

            var physicalFileSystem = new PhysicalFileSystem(ConfigurationManager.AppSettings["ClientPath"]);

            var options = new FileServerOptions
            {
                StaticFileOptions =
                {
                    FileSystem            = physicalFileSystem,
                    ServeUnknownFileTypes = true
                }
            };

            appBuilder.UseFileServer(options);
        }
Example #13
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.Routes.MapHttpRoute(
                name: "OauthHandlers",
                routeTemplate: "oauth/{controller}/{param}",
                defaults: new { param = RouteParameter.Optional });


            appBuilder.UseWebApi(config);

            appBuilder.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem  = new PhysicalFileSystem(@"..\..\default"),
            });
        }
Example #14
0
        public void Configuration(IAppBuilder app)
        {
            string exePath = Path.GetDirectoryName(Application.ExecutablePath);

            HttpConfiguration config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();

            app.UseWebApi(config);

            app.MapSignalR();

#if DEBUG
            var physicalFileSystem = new PhysicalFileSystem(@"C:\share\DJ2\WebAudioController\Web");
#else
            var physicalFileSystem = new PhysicalFileSystem(exePath + "\\Web");
#endif

            var options = new FileServerOptions
            {
                EnableDefaultFiles      = true,
                FileSystem              = physicalFileSystem,
                EnableDirectoryBrowsing = true
            };
            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[] { "index.html" };
            app.UseFileServer(options);
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            HttpConfiguration config = new HttpConfiguration();

            PhysicalFileSystem physicalFileSystem = new PhysicalFileSystem(@".\wwwroot");
            FileServerOptions fileOptions = new FileServerOptions();

            fileOptions.EnableDefaultFiles = true;
            fileOptions.RequestPath = PathString.Empty;
            fileOptions.FileSystem = physicalFileSystem;
            fileOptions.DefaultFilesOptions.DefaultFileNames = new[] {"Default.html"};
            fileOptions.StaticFileOptions.FileSystem = fileOptions.FileSystem = physicalFileSystem;
            fileOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            FormatterConfig.ConfigureFormatters(config.Formatters);
            RouteConfig.RegisterRoutes(config);

            appBuilder.UseWebApi(config);
            appBuilder.UseFileServer(fileOptions);

            //CORS & SignalR
            appBuilder.UseCors(CorsOptions.AllowAll);
            HubConfiguration configR = new HubConfiguration();
            configR.EnableDetailedErrors = true;
            appBuilder.MapSignalR(configR);

            GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => new SignalRUserIdProvider());

            config.EnsureInitialized();
        }
Example #16
0
        public void Configure(IAppBuilder app)
        {
            if (!string.IsNullOrWhiteSpace(this.Username) && !string.IsNullOrWhiteSpace(this.Password))
            {
                // if a username and password are supplied, enable basic auth
                app.Use(BasicAuth);
            }


            string dir  = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string path = Path.Combine(dir, @"Static");

            if (Directory.Exists(path))
            {
                app.UseFileServer(new FileServerOptions()
                {
                    RequestPath = PathString.Empty,
                    FileSystem  = new PhysicalFileSystem(path),
                });

                app.UseStaticFiles(new StaticFileOptions()
                {
                    RequestPath = new PathString("/Static"),
                    FileSystem  = new PhysicalFileSystem(path)
                });
            }
            app.Use(HandleRequest);
        }
Example #17
0
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
            //HttpConfiguration config = new HttpConfiguration();
            //config.Routes.MapHttpRoute(
            //    name: "DefaultWebApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);
            //app.UseWebApi(config);

            var physicalFileSystem = new PhysicalFileSystem(@"./Plugins");
            var options = new FileServerOptions {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "Index.html"
            };

            app.UseFileServer(options);

            app.MapSignalR();
        }
Example #18
0
        public void Configuration(IAppBuilder appBuilder)
        {
            var config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.Formatters.Clear();
            config.Formatters.Add(new JsonMediaTypeFormatter());
            config.Formatters.JsonFormatter.SerializerSettings =
                new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            appBuilder.UseWebApi(config);
            var options = new FileServerOptions
            {
                EnableDirectoryBrowsing = true,
                EnableDefaultFiles      = false,
                FileSystem        = new PhysicalFileSystem(Constants.PopcornTemp),
                StaticFileOptions = { ContentTypeProvider = new CustomContentTypeProvider() }
            };

            appBuilder.UseFileServer(options);
        }
Example #19
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );
            appBuilder.UseWebApi(config);
            Console.WriteLine("WebAPI Configured.");

            var physicalFileSystem = new PhysicalFileSystem(Program.FileSystemPath);
            var options            = new FileServerOptions
            {
                EnableDirectoryBrowsing = true,
                EnableDefaultFiles      = true,
                FileSystem = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[]
            {
                "index.html"
            };

            appBuilder.UseFileServer(options);
            Console.WriteLine("FileServer Configured. Serving {0}", physicalFileSystem.Root);
            config.EnsureInitialized();
        }
Example #20
0
        public void Configuration(IAppBuilder appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { action = "get", id = RouteParameter.Optional }
                );

            config.EnableSwagger(c =>
            {
                c.DocumentFilter <LowercaseDocumentFilter>();
                c.SingleApiVersion("v1", "WinMan");
            }).EnableSwaggerUi();

            var physicalFileSystem = new PhysicalFileSystem(@".\wwwroot");
            var options            = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[] { "default.html" };
            appBuilder.UseFileServer(options);

            appBuilder.UseCompressionModule();
            appBuilder.UseWebApi(config);
        }
Example #21
0
        public void Configuration(IAppBuilder app)
        {
            var configuration = new HttpConfiguration();

            configuration.MapHttpAttributeRoutes();
            configuration.EnsureInitialized();
            configuration.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings()
            {
                ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
            };
            LinkyConfiguration.Configure(configuration);
            app.UseWebApi(configuration);

            app.UseDefaultFiles(new DefaultFilesOptions()
            {
                DefaultFileNames = new[] { "index.html" }
            });
            app.UseFileServer(new FileServerOptions()
            {
                FileSystem         = new PhysicalFileSystem(@".\content"),
                RequestPath        = PathString.Empty,
                EnableDefaultFiles = true
            });

            app.Run((context) =>
            {
                var task = context.Response.WriteAsync("Hello world!");
                return(task);
            });
        }
Example #22
0
        public void Configuration(IAppBuilder app)
        {
            // Configure Web API for self-host.
            var config = new HttpConfiguration();

            config.EnableCors();

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional });

            config.DependencyResolver = new Resolver(ServiceProviderBuilder.BuildServiceProvider());

            app.Use <LoggingMiddelware>();

            app.UseWebApi(config);

            var physicalFileSystem = new PhysicalFileSystem(@".\wwwroot");
            var options            = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem,
                StaticFileOptions  =
                {
                    FileSystem            = physicalFileSystem,
                    ServeUnknownFileTypes = true
                },
                DefaultFilesOptions = { DefaultFileNames = new[] { "index.html" } }
            };

            app.UseFileServer(options);
        }
Example #23
0
        public void Configuration(IAppBuilder app)
        {
            var apiConfig = new HttpConfiguration();

            apiConfig.MapHttpAttributeRoutes();
            app.UseWebApi(apiConfig);

            var fileSystem = new PhysicalFileSystem("wwwroot");

            var staticFilesConfig = new FileServerOptions
            {
                FileSystem = fileSystem
            };

            staticFilesConfig.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "index.html"
            };
            app.UseFileServer(staticFilesConfig);

            app.Run(async context => {
                context.Response.StatusCode = 404;
                await context.Response.WriteAsync("Resource not found!");
            });
        }
        /// <summary>
        /// Ignore all routing from files, use HtmlRootFolder
        /// </summary>
        /// <param name="app"></param>
        private void ConfigureMiddleware(IAppBuilder app)
        {
            // create the html root folder if it doesn't exist
            var  folderLocation = ContentUpdater.GetFolderLocation("");
            bool exists         = Directory.Exists(folderLocation);

            if (!exists)
            {
                Directory.CreateDirectory(folderLocation);
            }


            var physicalFileSystem = new PhysicalFileSystem(@"./" + StandingData.HtmlRootFolder);

            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[]
            {
                "index.html"
            };

            app.UseFileServer(options);
        }
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath             = new PathString(string.Empty),
                FileSystem              = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #26
0
        public void Configuration(IAppBuilder app)
        {
            string strExeFilePath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string exePath        = Path.GetDirectoryName(strExeFilePath);


            HttpConfiguration config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();

            app.UseWebApi(config);

#if DEBUG
            exePath = Directory.GetParent(Directory.GetParent(exePath).FullName).FullName;
#endif
            var physicalFileSystem = new PhysicalFileSystem(exePath + "\\Web");

            var options = new FileServerOptions
            {
                EnableDefaultFiles      = true,
                FileSystem              = physicalFileSystem,
                EnableDirectoryBrowsing = true
            };
            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[] { "index.html" };
            app.UseFileServer(options);
        }
Example #27
0
        public void Configuration(IAppBuilder app)
        {
            // STEP Map Folder Paths
            const string clientRootFolder = @"..\..\..\";
            DirectoryInfo webDirectory = null;

            webDirectory = new DirectoryInfo(clientRootFolder + @"Sitter.Client\src\build");

            ValidateDirectory(webDirectory);

            // Path to index
            var fsOptions = new FileServerOptions
            {
                EnableDirectoryBrowsing = true,
                FileSystem = new PhysicalFileSystem(webDirectory.FullName)
            };

            app.UseFileServer(fsOptions);

            // Self-host the WebApi
            var config = new HttpConfiguration();
            WebApiConfig.Register(config);
            IoCConfig.Register(config);
            app.UseWebApi(config);
        }
Example #28
0
        public void Configuration(IAppBuilder app)
        {
            // ************************
            // Configure the static files. Middleware
            // ************************

            const string rootFolder = "./wwwroot";
            var          fileSystem = new PhysicalFileSystem(rootFolder);
            var          options    = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = fileSystem
            };

            app.UseFileServer(options);


            // ************************
            // Web.API Middleware
            // ************************

            //Configure Web API.
            //var config = new HttpConfiguration();
            //config.Routes.MapHttpRoute(
            //    "DefaultApi",
            //    "api/{controller}/{id}",
            //    new { id = RouteParameter.Optional }
            //);
            //app.UseWebApi(config);

            var config = new HttpConfiguration();

            config.MapHttpAttributeRoutes();
            app.UseWebApi(config);
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            var physicalFileSystem = new PhysicalFileSystem(@"C:\Work\Advanced\ACSStarTrek\ACS.Client");
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "index.html"
            };

            appBuilder.UseFileServer(options);

            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            appBuilder.UseWebApi(config);
        }
Example #30
0
        public void Configuration(IAppBuilder app)
        {
            // app.UseFilter(req => req.TraceOutput.WriteLine(
            //    "{0} {1}{2} {3}",
            //    req.Method, req.PathBase, req.Path, req.QueryString));

            app.UseErrorPage();
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.UseType <CanonicalRequestPatterns>();

            app.UseFileServer(opt => opt.WithPhysicalPath("Public"));

            app.MapPath("/static-compression", map => map
                        .UseStaticCompression()
                        .UseFileServer(opt =>
            {
                opt.WithDirectoryBrowsing();
                opt.WithPhysicalPath("Public");
            }));

            app.MapPath("/danger", map => map
                        .UseStaticCompression()
                        .UseFileServer(opt =>
            {
                opt.WithDirectoryBrowsing();
                opt.StaticFileOptions.ServeUnknownFileTypes = true;
            }));

            app.UseDiagnosticsPage("/testpage");
        }
Example #31
0
        private static void UseFileServer(IAppBuilder app, ILifetimeScope container)
        {
            var configuration = container.Resolve <IConfiguration>();

            if (!configuration.EnableManagementWeb)
            {
                return;
            }

            try
            {
                var options = new FileServerOptions()
                {
                    FileSystem  = new PhysicalFileSystem("ManagementWeb"),
                    RequestPath = new PathString("/managementweb"),
                };
                options.DefaultFilesOptions.DefaultFileNames.Add("index.html");

                app.UseFileServer(options);
            }
            catch (DirectoryNotFoundException)
            {
                // no admin web deployed - catch silently
            }
        }
Example #32
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            Type t2 = typeof(BankA.Controllers.Controllers.AccountsController);
            Type t3 = typeof(BankA.Controllers.Controllers.ReportsController);
            Type t4 = typeof(BankA.Controllers.Controllers.TransactionsController);



            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            config.EnableCors(new EnableCorsAttribute("*", "*", "*"));

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { controller = "Home", id = RouteParameter.Optional }
                );

            appBuilder.UseErrorPage();

            appBuilder.UseFileServer(new FileServerOptions()
            {
                FileSystem = new PhysicalFileSystem(GetRootDirectory()),
                EnableDirectoryBrowsing = true,
                RequestPath             = new Microsoft.Owin.PathString("/html")
            });

            appBuilder.UseWebApi(config);
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            //hosting static files i.e. angular
            //install-package Microsoft.Owin.SelfHost
            //install-package Microsoft.Owin.StaticFiles
            var options = new FileServerOptions();

            options.EnableDirectoryBrowsing = true;
            options.FileSystem = new PhysicalFileSystem("./app");
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            appBuilder.UseFileServer(options);


            // Configure Web API for self-host.
            //Install-Package Microsoft.AspNet.WebApi.OwinSelfHost
            HttpConfiguration config = new HttpConfiguration();

            config.Formatters.Remove(config.Formatters.XmlFormatter);

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            config.MapHttpAttributeRoutes();
            appBuilder.UseWebApi(config);


            //Install-Package Microsoft.Owin.Cors
            appBuilder.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
        }
Example #34
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            WebApiConfig.Register(config);

            config.DependencyResolver = new UnityDependencyResolver(UnityConfig.GetConfiguredContainer());
            AutoMapperGenerator.GenerateMappings();

            var physicalFileSystem = new PhysicalFileSystem(@".\wwwroot");
            var options            = new FileServerOptions
            {
                RequestPath        = PathString.Empty,
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.DefaultFilesOptions.DefaultFileNames    = new[] { "index.html" };
            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            app.UseFileServer(options);

            app.Use(async(context, next) => {
                await next();

                if (context.Response.StatusCode == 404 && !System.IO.Path.HasExtension(context.Request.Path.Value))
                {
                    context.Request.Path = new PathString("/wwwroot/index.html"); // Put your Angular root page here
                    await next();
                }
            });

            app.UseWebApi(config);
            app.UseStaticFiles();
        }
Example #35
0
        public void Configuration(IAppBuilder app)
        {
            var apiConfig = new HttpConfiguration();

            ConfigureOData(apiConfig);

            apiConfig.Routes.MapHttpRoute("default", "api/{controller}/{action}");
            app.UseWebApi(apiConfig);

            var fileSystem         = new PhysicalFileSystem("wwwroot");
            var defaultFileOptions = new DefaultFilesOptions();

            var staticFilesConfig = new FileServerOptions
            {
                FileSystem         = fileSystem,
                EnableDefaultFiles = true,
            };

            staticFilesConfig.DefaultFilesOptions.DefaultFileNames.Clear();
            staticFilesConfig.DefaultFilesOptions.DefaultFileNames.Add("index.html");

            app.UseFileServer(staticFilesConfig);

            app.Run(context =>
            {
                context.Response.ContentType = "text/plain";
                return(context.Response.WriteAsync("OWIN here!"));
            });
        }
        public void Configuration(IAppBuilder appBuilder)
        {
            var physicalFileSystem = new PhysicalFileSystem(@"C:\Work\Advanced\ACSStarTrek\ACS.Client");
            var options            = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[]
            {
                "index.html"
            };

            appBuilder.UseFileServer(options);

            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            appBuilder.UseWebApi(config);
        }
Example #37
0
        public void Configuration(IAppBuilder app)
        {
            //http://thorium.github.io/Owin.Compression/
            app.Map("/identity", idsrvApp =>
            {
                var factory = new IdentityServerServiceFactory();

                factory.UserService = new Registration <IUserService, UserService>();
                factory.ClientStore = new Registration <IClientStore, ClientService>();
                factory.ScopeStore  = new Registration <IScopeStore, ScopeService>();
                factory.ViewService = new Registration <IViewService, CustomViewService>();

                idsrvApp.UseIdentityServer(
                    new IdentityServerOptions
                {
                    SiteName              = "Standalone Identity Server",
                    SigningCertificate    = LoadCertificate(),
                    Factory               = factory,
                    RequireSsl            = false,
                    AuthenticationOptions = new AuthenticationOptions()
                    {
                        IdentityProviders = ConfigureIdentityProviders
                    }
                });
            });

            app.UseFileServer("/Content");
        }
Example #38
0
        public void Configuration(IAppBuilder app)
        {
            var relativePath = string.Format(@"..{0}..{0}", Path.DirectorySeparatorChar);
            var contentPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), relativePath);

            app.UseErrorPage();

            app.Use(async (ctx, next) =>
            {
                await next();
                Console.WriteLine($"{DateTime.Now.ToLongTimeString()}: {ctx.Request.Method} {ctx.Request.Uri.AbsolutePath}: {ctx.Response.StatusCode} {ctx.Response.ReasonPhrase}");
            });

            app.UseFileServer(new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(Path.Combine(contentPath, @"wwwroot")),
                EnableDirectoryBrowsing = false
            });

            var config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(config);
        }
Example #39
0
        public void Configuration(IAppBuilder app)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

            // Enable attribute based routing
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseCors(CorsOptions.AllowAll);
            app.UseWebApi(config);

            // Configure Web API for static files
            var physicalFileSystem = new PhysicalFileSystem(@".\www");
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" };
            app.UseFileServer(options);
        }
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder app)
        {

            HttpConfiguration config = new HttpConfiguration();
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
				routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
            app.UseWebApi(config);
            
            

			var root = Directory.GetParent(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)).Parent.FullName;
			var physicalFileSystem = new PhysicalFileSystem(root);

			var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "app\\index.html"
            };

            app.UseFileServer(options);
        }
Example #41
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {

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

            appBuilder.UseStaticFiles("/Views");
            appBuilder.UseStaticFiles("/Scripts");
            appBuilder.UseStaticFiles("/js");
            appBuilder.UseStaticFiles("/Content");

            // Configure Web API for self-host. 
            HttpConfiguration config = new HttpConfiguration();

            //  Enable attribute based routing
            //  http://www.asp.net/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2
            config.MapHttpAttributeRoutes();

            // Remove the XML formatter
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            config.Routes.MapHttpRoute(
                name: "AfterglowAPI",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            appBuilder.UseWebApi(config);
        } 
        public void Configuration(IAppBuilder appBuilder)
        {
            HttpConfiguration config = new HttpConfiguration();

            PhysicalFileSystem physicalFileSystem = new PhysicalFileSystem(@".\wwwroot");
            FileServerOptions fileOptions = new FileServerOptions();

            fileOptions.EnableDefaultFiles = true;
            fileOptions.RequestPath = PathString.Empty;
            fileOptions.FileSystem = physicalFileSystem;
            fileOptions.DefaultFilesOptions.DefaultFileNames = new[] {"index.html"};
            fileOptions.StaticFileOptions.FileSystem = fileOptions.FileSystem = physicalFileSystem;
            fileOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            try
            {
                config.MessageHandlers.Add(new ProxyHandler(this.configSettings));

                appBuilder.UseWebApi(config);
                appBuilder.UseFileServer(fileOptions);
            }
            catch (Exception e)
            {
                Trace.WriteLine(e);
            }
        }
Example #43
0
        public void Configuration(IAppBuilder app)
        {
            // app.UseFilter(req => req.TraceOutput.WriteLine(
            //    "{0} {1}{2} {3}",
            //    req.Method, req.PathBase, req.Path, req.QueryString));

            app.UseErrorPage();
            // app.Use(typeof(AutoTuneMiddleware), app.Properties["Microsoft.Owin.Host.HttpListener.OwinHttpListener"]);
            app.UseSendFileFallback();
            app.UseType<CanonicalRequestPatterns>();

            app.UseFileServer(opt => opt.WithPhysicalPath("Public"));

            app.MapPath("/static-compression", map => map
                .UseStaticCompression()
                .UseFileServer(opt =>
                {
                    opt.WithDirectoryBrowsing();
                    opt.WithPhysicalPath("Public");
                }));

            app.MapPath("/danger", map => map
                .UseStaticCompression()
                .UseFileServer(opt =>
                {
                    opt.WithDirectoryBrowsing();
                    opt.StaticFileOptions.ServeUnknownFileTypes = true;
                }));

            app.UseDiagnosticsPage("/testpage");
        }
Example #44
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            var config = new HttpConfiguration();
            
            //config.Routes.MapHttpRoute(
            //    name: "DefaultApi",
            //    routeTemplate: "api/{controller}/{id}",
            //    defaults: new { id = RouteParameter.Optional }
            //);

            // web api
            config.MapHttpAttributeRoutes();

            // static files
            appBuilder.UseFileServer(new FileServerOptions
            {
                FileSystem = new EmbeddedResourceFileSystem(typeof(Startup).Assembly, "Jukebox.Device.Web")
            });

            config.EnsureInitialized();

            appBuilder.UseWebApi(config);

            config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
        } 
Example #45
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {

                        // Configure Web API for self-host. 
            HttpConfiguration config = ConfigurationBuilder.HttpConfiguration;
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute("MyROute", "jobs/{name}/trigger", new {controller = "Jobs", action = "PostTriggerJob"});


            appBuilder.UseFileServer(new FileServerOptions()
            {
                FileSystem = new PhysicalFileSystem("./Assets/assets"),
                RequestPath = new PathString("/assets")
            });

            
            appBuilder.Map("/quartzadmin", builder => builder.UseNancy());

            appBuilder.Map("/api", builder => builder.UseWebApi(config));

            


            //appBuilder.UseWebApi(config);
        }
        private void ConfigureFileServer(IAppBuilder app, HostConfig config)
        {
            // use a file server to serve all static content (js, css, content, html, ...) and also configure default files (eg: index.html to be the default entry point)

            // create file system that will locate the files
            var fileSystem = AggregateFileSystem.FromWebUiPhysicalPaths(config.RootDirectory);

            // setup default documents
            app.UseDefaultFiles(new DefaultFilesOptions
            {
                FileSystem = fileSystem,
                DefaultFileNames = new List<string>
                {
                    "views/index.html"
                }
            });


            // start file server to share website static content
            // wrapper around: StaticFiles + DefaultFiles + DirectoryBrowser
            var fileServerOptions = new FileServerOptions
            {
                EnableDirectoryBrowsing = false,
                FileSystem = fileSystem,
            };

            fileServerOptions.StaticFileOptions.ContentTypeProvider = new FileServerContentTypeProvider();

            app.UseFileServer(fileServerOptions);
        }
        public void Configuration(IAppBuilder app)
        {
            app.UseWelcomePage(new PathString("/Welcome"));

            app.UseFileServer(new FileServerOptions
            {
                EnableDirectoryBrowsing = false,
                FileSystem = new PhysicalFileSystem(@"..\..\..\KatanaApp\StaticResources"),
                RequestPath = new PathString(@"/contents")
            });

            app.Run(ctx =>
            {
                if (string.IsNullOrEmpty(ctx.Request.Path.Value) || ctx.Request.Path.Value == "/" || ctx.Request.Path.Value == "/Welcome/")
                {
                    ctx.Response.Redirect("/app/Welcome");
                }
                // New code: Throw an exception for this URI path.
                if (ctx.Request.Path.Value == @"/fail")
                {
                    throw new HttpException(500, "Random exception");
                }
                ctx.Response.ContentType = "text/plain";
                return ctx.Response.WriteAsync("Hello World!");
            });
        }
Example #48
0
		public void Configuration(IAppBuilder app)
		{
#if DEBUG
			app.UseErrorPage();
#endif
			
			app.Use(
				async (context, next) =>
				{
					// Log all exceptions and incoming requests
					Console.WriteLine("{0} {1} {2}", context.Request.Method, context.Request.Path, context.Request.QueryString);

					try
					{
						await next();
					}
					catch (Exception exception)
					{
						Console.WriteLine(exception.ToString());
						throw;
					}
				});

			var contentFileSystem = new PhysicalFileSystem("Content");
			app.UseBabel(new BabelFileOptions() { StaticFileOptions = new StaticFileOptions() { FileSystem = contentFileSystem }});
			app.UseFileServer(new FileServerOptions() { FileSystem = contentFileSystem });

			app.Use<CommentsMiddleware>();
		}
Example #49
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // set response formatters
            httpConfiguration.Formatters.Clear();
            SetWebApiResponseAsJson(httpConfiguration);

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}"
                );

            httpConfiguration.Routes.MapHttpRoute(
                name: "Default",
                routeTemplate: "r/{hashId}",
                defaults: new { controller = "RedirectUrl" }
                );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./App/www"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #50
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            app.UseWebApi(config);

            //var physicalFileSystem = new PhysicalFileSystem(@"./www");
            var physicalFileSystem = new PhysicalFileSystem(ProxyWebServer.PATH_ROOT);
            var options            = new FileServerOptions
            {
                RequestPath        = new PathString(""),
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames    = new[]
            {
                "index.html",
                "spaHome.html",
                "spa.html"
            };
            app.UseFileServer(options);
        }
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            httpConfiguration.Formatters.Clear();
            httpConfiguration.Formatters.Add(new JsonMediaTypeFormatter());
            httpConfiguration.Formatters.JsonFormatter.SerializerSettings =
            new JsonSerializerSettings
            {
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./"),
                EnableDirectoryBrowsing = true,

            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #52
0
        public void Configuration(IAppBuilder app)
        {
            var httpConfiguration = new HttpConfiguration();

            // Configure Web API Routes:
            // - Enable Attribute Mapping
            // - Enable Default routes at /api.
            httpConfiguration.MapHttpAttributeRoutes();
            httpConfiguration.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            app.UseWebApi(httpConfiguration);

            // Make ./public the default root of the static files in our Web Application.
            app.UseFileServer(new FileServerOptions
            {
                RequestPath = new PathString(string.Empty),
                FileSystem = new PhysicalFileSystem("./public"),
                EnableDirectoryBrowsing = true,
            });

            app.UseStageMarker(PipelineStage.MapHandler);
        }
Example #53
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            //Database.SetInitializer<ServerContext>(null);

            // Configure Web API for self-host. 
            HttpConfiguration config = new HttpConfiguration();           
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );

            appBuilder.UseWebApi(config);

            var physicalFileSystem = new PhysicalFileSystem(@"./wwwroot");
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = physicalFileSystem
            };
            options.StaticFileOptions.FileSystem = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "index.html"
            };

            appBuilder.UseFileServer(options);
        }
Example #54
0
        public void Configuration(IAppBuilder app)
        {
            #if DEBUG
            //when things go south
            app.UseErrorPage();
            #endif

            FileServerOptions fileServerOptions = new FileServerOptions()
            {
                RequestPath = PathString.Empty,
                FileSystem = new PhysicalFileSystem(@".\\public"),
            };

            //In order to serve json files
            fileServerOptions.StaticFileOptions.ServeUnknownFileTypes = true;
            fileServerOptions.StaticFileOptions.DefaultContentType = "text";

            // Remap '/' to '.\public\'.
            // Turns on static files and public files.
            app.UseFileServer(fileServerOptions);

            app.UseStageMarker(PipelineStage.MapHandler);

            //Web Api
            HttpConfiguration config = new HttpConfiguration();
            config.MapHttpAttributeRoutes();

            //Cause all the cool kids use JSON
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;
            config.Formatters.Remove(config.Formatters.XmlFormatter);

            app.UseWebApi(config);
        }
Example #55
0
        public void Configuration(IAppBuilder app)
        {
            app.UseCors(CorsOptions.AllowAll);

            double tokenLifetime;

            double.TryParse(ConfigurationManager.AppSettings["AccessTokenLifetimeHours"], out tokenLifetime);

            // token configuration
            app.UseOAuthAuthorizationServer(new OAuthAuthorizationServerOptions
            {
                AllowInsecureHttp         = true,
                TokenEndpointPath         = new PathString("/api/auth/validate"),
                AccessTokenExpireTimeSpan = TimeSpan.FromHours(tokenLifetime != 0 ? tokenLifetime : 10),
                //Provider = new SimpleAuthorizationServerProvider()
                Provider = new CasAuthorizationServerProvider()
            });

            // token consumption
            app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions());

            HttpConfiguration config = new HttpConfiguration();

            app.UseWebApi(WebApiConfig.Register(config));

            // allow self-signed certificates
            ServicePointManager.ServerCertificateValidationCallback +=
                (sender, cert, chain, sslPolicyErrors) => true;

            // configure web root
            string webDir = ConfigurationManager.AppSettings["WebDirectory"];

            if (string.IsNullOrEmpty(webDir))
            {
                webDir = "Web";
            }
            app.UseFileServer(FileServerConfig.Create(PathString.Empty, webDir));

            // configure web root for /doc url
            string docDir = ConfigurationManager.AppSettings["DocDirectory"];

            if (string.IsNullOrEmpty(docDir))
            {
                docDir = "Doc";
            }
            app.UseFileServer(FileServerConfig.Create(new PathString("/doc"), docDir));
        }
Example #56
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public void Configuration(IAppBuilder appBuilder)
        {
            //registruji middleware odchytávající a zapisující vyjimky
            appBuilder.Use <GlobalExceptionMiddleware>();



            // Configure Web API for self-host.

            HttpConfiguration config = new HttpConfiguration();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{action}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");

            config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
            //config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"))

            appBuilder.Use <GlobalExceptionMiddleware>().UseWebApi(config);
            //appBuilder.UseWebApi(config);


            //A. nacitam z adresare www, ktery je soucasti solution
            //var physicalFileSystem = new PhysicalFileSystem(@"./WWW1");

            //B. nacitam z adresare ktery je mimo solution, dle nastaveni www.rootDir v  app.config
            var contentDir         = ConfigurationManager.AppSettings["www.rootDir"];
            var physicalFileSystem = new PhysicalFileSystem(contentDir);

            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem         = physicalFileSystem,
            };

            options.StaticFileOptions.FileSystem            = physicalFileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.StaticFileOptions.OnPrepareResponse     = (staticFileResponseContext) =>
            {
                staticFileResponseContext.OwinContext.Response.Headers.Add("Cache-Control",
                                                                           new[] { "public", "no-cache, no-store, must-revalidate, max-age=0" });
            };

            options.DefaultFilesOptions.DefaultFileNames = new[]
            {
                "menu.html"
            };

            appBuilder.UseFileServer(options);

            //appBuilder.UseStaticFiles(new StaticFileOptions()
            //{
            //    FileSystem = new PhysicalFileSystem(contentDir)
            //});
        }
        public void Configuration(IAppBuilder app)
        {
            app.UseFileServer(opts =>
            {
                opts.WithRequestPath("");
                opts.WithPhysicalPath("client");
                opts.WithDefaultFileNames("index.html");
            });
            app.UseFileServer(opts =>
            {
                opts.WithRequestPath("/images");
                opts.WithPhysicalPath("images");
            });

            var startup = new Startup();
            startup.Configuration(app);
        }
Example #58
0
 private void ConfigureStaticFiles(IAppBuilder app)
 {
     var publicPath = Path.Combine(HttpContext.Current.Server.MapPath("~/"), "public");
     app.UseFileServer(new FileServerOptions
     {
         EnableDirectoryBrowsing = true,
         FileSystem = new PhysicalFileSystem(publicPath)
     });
 }
Example #59
0
        public void EmbeddedFileSystemDefaultFilesConfiguration(IAppBuilder app)
        {
            FileServerOptions options = new FileServerOptions();
            options.FileSystem = new EmbeddedResourceFileSystem(Assembly.GetExecutingAssembly().GetName().Name);
            options.DefaultFilesOptions.DefaultFileNames.Clear();
            options.DefaultFilesOptions.DefaultFileNames.Add("RequirementFiles.EmbeddedResources.SampleHTM.htm");

            app.UseFileServer(options);
        }
Example #60
0
 public void Configuration(IAppBuilder app)
 {
     app.UseWebApi(Models.Config.GetHttpConfiguration());
     app.UseErrorPage();
     // the next line is needed for handling the UriPathExtensionMapping...
     app.UseStageMarker(PipelineStage.MapHandler);
     app.UseStaticFiles();
     app.UseFileServer(true);
 }