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);
            }
        }
        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();
        }
Esempio n. 3
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);
        }
Esempio n. 4
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();
        }
Esempio n. 5
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);
        }
Esempio n. 7
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>();
		}
        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);
        }
Esempio n. 9
0
        static void Main()
		{
            
            log.Info("Starting application");

            string baseUrl = "http://*****:*****@"C:\projects\LuxRecon\Lux.Recon.UI";
			var root = Directory.GetParent(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)).Parent.FullName;
			var fileSystem = new PhysicalFileSystem(root);

			WebApp.Start<Startup>(new StartOptions(baseUrl)
			{
				ServerFactory = "Microsoft.Owin.Host.HttpListener"
			});

			// Launch default browser
			Process.Start(baseUrl);

				// Create HttpCient and make a request to api/values 
				HttpClient client = new HttpClient();
				var response2 = client.GetAsync(baseUrl + "/main").Result;
				//Console.WriteLine(response2);
				//Console.WriteLine(response2.Content.ReadAsStringAsync().Result);
			

			Console.ReadLine();
			
		}
Esempio n. 10
0
        public static IDisposable Start(DirectoryPath path, int port, bool forceExtension)
        {
            IDisposable server;
            try
            {
                StartOptions options = new StartOptions("http://localhost:" + port);

                // Disable built-in owin tracing by using a null trace output
                // http://stackoverflow.com/questions/17948363/tracelistener-in-owin-self-hosting
                options.Settings.Add(typeof(ITraceOutputFactory).FullName, typeof(NullTraceOutputFactory).AssemblyQualifiedName);

                server = WebApp.Start(options, app =>
                {
                    Microsoft.Owin.FileSystems.IFileSystem outputFolder = new PhysicalFileSystem(path.FullPath);

                    // Disable caching
                    app.Use((c, t) =>
                    {
                        c.Response.Headers.Append("Cache-Control", "no-cache, no-store, must-revalidate");
                        c.Response.Headers.Append("Pragma", "no-cache");
                        c.Response.Headers.Append("Expires", "0");
                        return t();
                    });

                    // Support for extensionless URLs
                    if (!forceExtension)
                    {
                        app.UseExtensionlessUrls(new ExtensionlessUrlsOptions
                        {
                            FileSystem = outputFolder
                        });
                    }

                    // Serve up all static files
                    app.UseDefaultFiles(new DefaultFilesOptions
                    {
                        RequestPath = PathString.Empty,
                        FileSystem = outputFolder,
                        DefaultFileNames = new List<string> { "index.html", "index.htm", "home.html", "home.htm", "default.html", "default.html" }
                    });
                    app.UseStaticFiles(new StaticFileOptions
                    {
                        RequestPath = PathString.Empty,
                        FileSystem = outputFolder,
                        ServeUnknownFileTypes = true
                    });
                });
            }
            catch (Exception ex)
            {
                Trace.Critical("Error while running preview server: {0}", ex.Message);
                return null;
            }

            Trace.Information("Preview server listening on port {0} and serving from path {1}", port, path);
            return server;
        }
Esempio n. 11
0
            public void InitializesFileSystem()
            {
                // Arrange
                IFileSystem expected = new PhysicalFileSystem(@"C:\");

                // Act
                var router = new DefaultRouter(expected);

                // Assert
                Assert.Same(expected, router.FileSystem);
            }
        public static void Configure(IAppBuilder app)
        {
            const string rootFolder = ".";
            var fileSystem = new PhysicalFileSystem(rootFolder);
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = fileSystem
            };

            app.UseFileServer(options);
        }
Esempio n. 13
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();
            var container = CreateKernel();

            _backgroundTicker = new BackgroundTicker(container.Resolve<IHubMessageService>());

            app.UseAutofacMiddleware(container).UseAutofacWebApi(config);
            app.MapSignalR();
            WebApiConfig.Register(config);
            app.UseWebApi(config);

            var physicalFileSystem = new PhysicalFileSystem(@"..");
            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);

            ActorSystem StatsActorSystem = container.Resolve<IActorSystemFactory>().Create("StatsCoordinatorActor");
            MongoDbPersistence.Instance.Apply(StatsActorSystem);
            BsonClassMap.RegisterClassMap<CreateHitterMessage>(cm =>
            {
                cm.AutoMap();
            });
            BsonClassMap.RegisterClassMap<HitHomeRunMessage>(cm =>
            {
                cm.AutoMap();
            });

            BsonClassMap.RegisterClassMap<HomeRunHitEvent>(cm =>
            {
                cm.AutoMap();
            });
            BsonClassMap.RegisterClassMap<HitterAddedEvent>(cm =>
            {
                cm.AutoMap();
            });

            StatsActors stats = container.Resolve<StatsActors>();
            stats.statActorRef = StatsActorSystem.ActorOf(StatsActorSystem.DI().Props<StatsCoordinatorActor>()
                .WithRouter(new RoundRobinPool(2)), "StatsCoordinatorActor");
            stats.statCommandActorRef = StatsActorSystem.ActorOf(StatsActorSystem.DI().Props<StatsCoordinatorCommandActor>(), "StatsCoordinatorCommandActor");
            stats.statViewActorRef = StatsActorSystem.ActorOf(StatsActorSystem.DI().Props<StatsCoordinatorViewActor>(), "StatsCoordinatorViewActor");
        }
 public void Configuration(IAppBuilder app)
 {
     var physicalFileSystem = new PhysicalFileSystem("wwwroot");
     var options = new FileServerOptions
     {
         EnableDefaultFiles = true,
         FileSystem = physicalFileSystem
     };
     options.StaticFileOptions.FileSystem = physicalFileSystem;
     options.StaticFileOptions.ServeUnknownFileTypes = false;
     options.DefaultFilesOptions.DefaultFileNames = new[] { "index.html" };
     app.UseFileServer(options);
 }
Esempio n. 15
0
		public void Configuration(IAppBuilder app)
		{
			//logger for testing
			//app.Use(typeof (RequestLogger));

			app.MapSignalR();
			
			//Where our content lives
			string contentPath = Path.Combine(Environment.CurrentDirectory, @".\Modules\App\www");

			var physicalFileSystem = new PhysicalFileSystem(contentPath);
			var options = new FileServerOptions
			{
				EnableDefaultFiles = true,
				FileSystem = physicalFileSystem
			};
			options.StaticFileOptions.FileSystem = physicalFileSystem;
			options.StaticFileOptions.ServeUnknownFileTypes = true;
			options.DefaultFilesOptions.DefaultFileNames = new[] {"index.htm"}; //Default file to serve if none specified
			options.StaticFileOptions.OnPrepareResponse = _ => _.OwinContext.Response.Headers.Add("X-UA-Compatible", new [] { "IE=Edge" });
			app.UseFileServer(options);

			var config = new HttpConfiguration();
			
			// JSON stuff
			
			//config.Formatters.JsonFormatter.SerializerSettings.TypeNameHandling = TypeNameHandling.Auto;
			//config.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new StringEnumConverter());
			

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

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

			app.UseWebApi(config);

			

		}
Esempio n. 16
0
 private void ConfigureManager(IAppBuilder appBuilder)
 {
     var fileSystem = new PhysicalFileSystem("./Portal");
     appBuilder.UseDefaultFiles(new DefaultFilesOptions
     {
         DefaultFileNames = new[] {"index.html"},
         FileSystem = fileSystem
     });
     appBuilder.UseStaticFiles(new StaticFileOptions
     {
         RequestPath = new PathString(""),
         FileSystem = fileSystem,
         ServeUnknownFileTypes = true,
     });
 }
        public void Configuration(IAppBuilder appBuilder)
        {
            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 = physicalFileSystem;
            fileOptions.StaticFileOptions.ServeUnknownFileTypes = true;

            appBuilder.UseFileServer(fileOptions);
        }
        void ConfigureAdmin(IAppBuilder application)
        {
            var appFolder = FindAppRoot();

            var fileSystem = new PhysicalFileSystem(appFolder);

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

            application.UseFileServer(options);
        }
Esempio n. 19
0
        public TripContext(string fileDBLocation)
        {
            _fileDBLocation = fileDBLocation;

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;

            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {
                var json   = File.ReadAllText(fi.PhysicalPath);
                var result = JsonConvert.DeserializeObject <List <Trip> >(json);

                Trips = result.ToList();
            }
        }
Esempio n. 20
0
        public TripContext(string fileDBLocation)
        {
            _fileDBLocation = fileDBLocation;

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;
            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {

                var json = File.ReadAllText(fi.PhysicalPath);
                var result = JsonConvert.DeserializeObject<List<Trip>>(json);

                Trips = result.ToList();
            }
        }
Esempio n. 21
0
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
            var webRroot = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "app");
            var fileSystem = new PhysicalFileSystem(webRroot);

            var options = new FileServerOptions
            {
                EnableDirectoryBrowsing = false,
                FileSystem = fileSystem
            };

            options.StaticFileOptions.RequestPath = new PathString("/app");

            app.UseFileServer(enableDirectoryBrowsing:true);
        }
        public bool SaveChanges()
        {
            // write trips to json file, overwriting the old one

            var json = JsonConvert.SerializeObject(Trips);

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;
            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {
                File.WriteAllText(fi.PhysicalPath, json);
                return true;
            }

            return false;
        }
        public static void Register(IAppBuilder app)
        {
            var physicalFileSystem = new PhysicalFileSystem(@"./");
            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 appBuilder)
        {
            // Configure Web API for self-host.
            HttpConfiguration config = new HttpConfiguration();

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

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

            config.Routes.MapHttpRoute(
                name: "Fallback",
                routeTemplate: "{name}/{*other}",
                defaults: new { controller = "Home", action = "Index" },
                constraints: new { name = "^(?!(api|controller|css|fonts|img|js)$).*$" }
            );

            appBuilder.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
            appBuilder.UseWebApi(config);

            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"
            };

            config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize;
            config.Formatters.JsonFormatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;

            appBuilder.UseFileServer(options);
        }
        public void Configure(IAppBuilder app)
        {
            IFileSystem fs;

            if (Debugger.IsAttached)
                fs = new PhysicalFileSystem("../../../Magistrate/client");
            else
                fs = new AssemblyResourceFileSystem(Assembly.GetExecutingAssembly(), "Magistrate.client");

            var fileOptions = new FileServerOptions
            {
                FileSystem = fs,
                EnableDefaultFiles = true,
                DefaultFilesOptions = { DefaultFileNames = { "app.htm" } }
            };

            app.UseFileServer(fileOptions);
        }
Esempio n. 26
0
        public bool SaveChanges()
        {
            // write trips to json file, overwriting the old one

            var json = JsonConvert.SerializeObject(Trips);

            var fileSystem = new Microsoft.Owin.FileSystems.PhysicalFileSystem("");

            IFileInfo fi;

            if (fileSystem.TryGetFileInfo(_fileDBLocation, out fi))
            {
                File.WriteAllText(fi.PhysicalPath, json);
                return(true);
            }

            return(false);
        }
        public static IAppBuilder UseHtml5Routing(this IAppBuilder builder, string rootPath, string entryPath)
        {
            var fileSystem = new PhysicalFileSystem(rootPath);
            var fileServerOptions = new FileServerOptions()
            {
                EnableDirectoryBrowsing = false,
                FileSystem = fileSystem
            };
            var options = new HTML5ServerOptions()
            {
                FileServerOptions = fileServerOptions,
                EntryPath = new PathString(entryPath)
            };

            builder.UseDefaultFiles(options.FileServerOptions.DefaultFilesOptions);

            return builder.Use(new Func<AppFunc, AppFunc>(next => new Html5Middleware(next, options).Invoke));
        }
Esempio n. 28
0
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();

            var staticFilesPath = GetStaticFilesPath();
            var fileSystem = new PhysicalFileSystem(staticFilesPath);

            var fileServerOptions = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = fileSystem
            };
            fileServerOptions.StaticFileOptions.FileSystem = fileSystem;
            fileServerOptions.StaticFileOptions.ServeUnknownFileTypes = true;
            fileServerOptions.DefaultFilesOptions.DefaultFileNames = new[] { "index.html", "index.htm" };

            app.UseFileServer(fileServerOptions);
        }
        /// <summary>
        /// Configure OWIN static file hosting
        /// </summary>
        /// <param name="app">IAppBuilder</param>
        /// <param name="root">Root path to host</param>
        /// <param name="defaultFileNames">Default file names to host</param>
        public static void UseStaticFileHosting(this IAppBuilder app, string root, string[] defaultFileNames)
        {
            //The file system for the server to host
            var fileSystem = new PhysicalFileSystem(root);

            //File server configuration options
            var options = new FileServerOptions
            {
                EnableDefaultFiles = true,
                FileSystem = fileSystem
            };

            options.StaticFileOptions.FileSystem = fileSystem;
            options.StaticFileOptions.ServeUnknownFileTypes = true;
            options.DefaultFilesOptions.DefaultFileNames = defaultFileNames;

            app.UseFileServer(options);
        }
Esempio n. 30
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
                });
        }
Esempio n. 31
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration configuration = new HttpConfiguration();

            // SignalR
            app.MapSignalR();

            //// Make sure we're shipping our own provider
            //var dependencyResolver = Microsoft.AspNet.SignalR.GlobalHost.DependencyResolver;
            //dependencyResolver.Register(typeof(Microsoft.AspNet.SignalR.Hubs.IHubDescriptorProvider), () => new EcoHubDescriptorProvider(dependencyResolver));

            // Web API
            app.UseWebApi(configuration);

            // Static files
            var staticFilesDirectory = _webRoot.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
            if (!Directory.Exists(staticFilesDirectory))
                throw new InvalidOperationException($"Could not find webroot directory at {staticFilesDirectory}. Please check your installation.");

            var fileSystem = new PhysicalFileSystem(staticFilesDirectory);
            var requestPath = PathString.Empty;

            app.UseDefaultFiles(new DefaultFilesOptions
            {
                DefaultFileNames = new List<string> { "index.html" },
                FileSystem = fileSystem,
                RequestPath = requestPath
            });

            app.UseStaticFiles(new StaticFileOptions
            {
                FileSystem = fileSystem,
                RequestPath = requestPath,
                ServeUnknownFileTypes = false
            });

            app.Run(async (context) =>
            {
                var response = context.Response;
                response.StatusCode = 404;
                response.ReasonPhrase = "Not Found";
                await response.WriteAsync(@"<!DOCTYPE html><html><head><title>404 - Not Found</title></head><body><h1>404 - Not Found</h1></body></html>");
            });
        }
Esempio n. 32
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
            });
        }