当前位置: 首页>>代码示例>>C#>>正文


C# IAppBuilder.UseFileServer方法代码示例

本文整理汇总了C#中IAppBuilder.UseFileServer方法的典型用法代码示例。如果您正苦于以下问题:C# IAppBuilder.UseFileServer方法的具体用法?C# IAppBuilder.UseFileServer怎么用?C# IAppBuilder.UseFileServer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAppBuilder的用法示例。


在下文中一共展示了IAppBuilder.UseFileServer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configuration

        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>();
        }
开发者ID:jormenjanssen,项目名称:Soundboard,代码行数:25,代码来源:PortalStartup.cs

示例2: Configuration

        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();
        }
开发者ID:andreychizhov,项目名称:microsoft-aspnet-samples,代码行数:35,代码来源:Startup.cs

示例3: Configuration

        // 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");
        }
开发者ID:srihari-sridharan,项目名称:Programming-Playground,代码行数:28,代码来源:Startup.cs

示例4: Configuration

        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();
        }
开发者ID:Wolfium,项目名称:AngularJSSignalRDashboard,代码行数:25,代码来源:Startup.cs

示例5: Configuration

        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();
        }
开发者ID:Kacetsu,项目名称:NidhoggStudio,代码行数:27,代码来源:OwinStartup.cs

示例6: Configuration

        // 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;
        } 
开发者ID:mwinkler,项目名称:RaspberryPi.Musicbox,代码行数:27,代码来源:Startup.cs

示例7: Configuration

        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");
        }
开发者ID:tkggand,项目名称:katana,代码行数:31,代码来源:Startup.cs

示例8: Configuration

        // 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);
        }
开发者ID:kaleyroy,项目名称:QuartzNetAPI,代码行数:34,代码来源:Startup.cs

示例9: ConfigureFileServer

        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);
        }
开发者ID:btcioner,项目名称:novaburst.ModularTypeScript,代码行数:30,代码来源:Startup.cs

示例10: Configuration

		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>();
		}
开发者ID:RichardD012,项目名称:React.NET,代码行数:29,代码来源:Startup.cs

示例11: Configuration

        // 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);
        }
开发者ID:kamalm87,项目名称:WebScaleFileManage,代码行数:32,代码来源:OwinSelfhostSample.cs

示例12: Configuration

        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);
        }
开发者ID:herki18,项目名称:ACSStarTrek,代码行数:27,代码来源:CrewManifestsStartup.cs

示例13: Configuration

        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);
        }
开发者ID:sgh1986915,项目名称:.net-braintree-spa,代码行数:25,代码来源:Startup.cs

示例14: Configuration

        // 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);
        }
开发者ID:thinktecture,项目名称:windows-js-integration-demos,代码行数:27,代码来源:Startup.cs

示例15: Configuration

        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();
        }
开发者ID:Azure-Samples,项目名称:service-fabric-dotnet-data-streaming-websockets,代码行数:30,代码来源:Startup.cs


注:本文中的IAppBuilder.UseFileServer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。