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


C# IBuilder.UseStaticFiles方法代码示例

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


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

示例1: Configure

        public void Configure(IBuilder app, ILibraryManager libManager, IApplicationShutdown shutdown)
        {
            var web = libManager.GetLibraryInformation("Runt.Web");

            Console.WriteLine("Path: " + web.Path);
            Console.WriteLine("Name: " + web.Name);
            var fileSystem = new PhysicalFileSystem(Path.GetDirectoryName(web.Path));

            app.UseServices(services =>
            {
                services.AddSignalR();
                services.AddSingleton<IEditor, Editor>();
            });

            app.UseSignalR("/io", typeof(RuntConnection), new ConnectionConfiguration
            {
                EnableJSONP = false
            });
            app.UseDefaultFiles(new DefaultFilesOptions
            {
                FileSystem = fileSystem
            });
            app.UseStaticFiles(new StaticFileOptions
            {
                FileSystem = fileSystem,
                ContentTypeProvider = contentTypeProvider,
                ServeUnknownFileTypes = true
            });
            app.UseDirectoryBrowser(new DirectoryBrowserOptions
            {
                FileSystem = fileSystem
            });
        }
开发者ID:Runt-Editor,项目名称:Runt,代码行数:33,代码来源:Startup.cs

示例2: Configure

        public void Configure(IBuilder app)
        {
            // Setup configuration sources
            var configuration = new Configuration();
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            // Set up application services
            app.UseServices(services =>
            {
                // Add MVC services to the services container
                services.AddMvc();
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default", 
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:julid29,项目名称:confsamples,代码行数:30,代码来源:Startup.cs

示例3: Configure

        public void Configure(IBuilder app)
        {
            // Setup configuration sources
            var configuration = new Configuration();
            configuration.AddEnvironmentVariables();

            app.UseOwin();

            // Set up application services
            app.UseServices(services =>
            {                // Add MVC services to the services container
                services.AddMvc();
                services.SetupOptions<MvcOptions>(options => {
                    System.Diagnostics.Debug.WriteLine(options.OutputFormatters.Select(item => item.GetType().Name));

                    options.OutputFormatters.RemoveAt(0);
                });
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                //routes.MapRoute(
                //    name: "default",
                //    template: "{controller}/{action}/{id?}",
                //    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:niklaslundberg,项目名称:VisualStudio-UF,代码行数:35,代码来源:Startup.cs

示例4: Configure

        public void Configure(IBuilder app)
        {
            // Enable Browser Link support
            app.UseBrowserLink();

            // Setup configuration sources
            var configuration = new Configuration();
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            // Set up application services
            app.UseServices(services =>
            {
                // Add EF services to the services container
                services.AddEntityFramework()
                    .AddSqlServer();

                // Configure DbContext
                services.SetupOptions<DbContextOptions>(options =>
                {
                    options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
                });

                // Add Identity services to the services container
                services.AddIdentity<ApplicationUser>()
                    .AddEntityFramework<ApplicationUser, ApplicationDbContext>()
                    .AddHttpSignIn();

                // Add MVC services to the services container
                services.AddMvc();
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login"),
            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:chsword,项目名称:chsns,代码行数:55,代码来源:Startup.cs

示例5: Configure

 public void Configure(IBuilder app)
 {
     // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
     app.UseServices(services =>
     {
         services.AddMvc();
     });
     // Add static files to the request pipeline
     app.UseStaticFiles();
     app.UseMvc();
 }
开发者ID:JulioCL,项目名称:HearthStone,代码行数:11,代码来源:Startup.cs

示例6: Configure

        public void Configure(IBuilder app)
        {
            // Enable Browser Link support
            app.UseBrowserLink();

            // Setup configuration sources
            var configuration = new Configuration();

            //configuration.AddIniFile("config.ini");
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            //app.Run(async context =>
            //{
            //    await context.Response.WriteAsync(configuration.Get("Data:Configuration"));
            //});

            app.Run(async context =>
            {
                var asm = Assembly.Load(new AssemblyName("klr.host"));
                var assemblyVersion = asm.GetCustomAttribute<AssemblyInformationalVersionAttribute>();

                await context.Response.WriteAsync(assemblyVersion.InformationalVersion);
            });

            // Set up application services
            app.UseServices(services =>
            {
                // Add EF services to the services container
                services.AddEntityFramework().AddInMemoryStore();
                services.AddScoped<PersonContext>();

                // Add MVC services to the services container
                services.AddMvc();
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default", 
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
开发者ID:julid29,项目名称:confsamples,代码行数:52,代码来源:Startup.cs

示例7: Configure

        public void Configure(IBuilder app)
        {
            app.UseServices(services =>
            {
                services.AddMvc();
            });

            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:16,代码来源:Startup.cs

示例8: Configure

        public void Configure(IBuilder app)
        {
            var configuration = new Configuration();
            configuration.AddEnvironmentVariables();

            // Set up application services
            app.UseServices(services =>
            {
                services.Add(OptionsServices.GetDefaultServices());
                services.SetupOptions<BlobStorageOptions>(options =>
                {
                    options.ConnectionString = configuration.Get("ReversePackageSearch:BlobStorageConnection");
                });
                // Add MVC services to the services container
                services.AddMvc();
            });

            // Add static files
            app.UseStaticFiles(new StaticFileOptions { FileSystem = new PhysicalFileSystem("content") });
            // Add MVC to the request pipeline
            app.UseMvc();
        }
开发者ID:yintai,项目名称:ReversePackageSearch,代码行数:22,代码来源:Startup.cs

示例9: Configure

        public void Configure(IBuilder app)
        {
            var configuration = new Configuration();
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            app.UseServices(services =>
            {
                services.AddMvc();
                services.AddModules();
            });

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapModuleRoute();

                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });
        }
开发者ID:kulmugdha,项目名称:Entropy,代码行数:24,代码来源:Startup.cs

示例10: Configure

        public void Configure(IBuilder app)
        {
            var configuration = new Configuration()
                .AddJsonFile("Config.json")
                .AddEnvironmentVariables();

            app.UseServices(services =>
            {
                // Add options accessors to the service container
                services.SetupOptions<IdentityDbContextOptions>(options =>
                {
                    options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
                    options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
                    options.UseSqlServer(configuration.Get("Data:IdentityConnection:ConnectionString"));
                });

                services.SetupOptions<MusicStoreDbContextOptions>(options =>
                    options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString")));

                // Add MVC services to the service container
                services.AddMvc();

                // Add EF services to the service container
                services.AddEntityFramework()
                    .AddSqlServer();

                // Add Identity services to the service container
                services.AddIdentitySqlServer<ApplicationDbContext, ApplicationUser>()
                    .AddAuthentication();

                // Add application services to the service container
                services.AddScoped<MusicStoreContext>();
                services.AddTransient(typeof(IHtmlHelper<>), typeof(AngularHtmlHelper<>));
            });

            // Initialize the sample data
            SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
            SampleData.InitializeIdentityDatabaseAsync(app.ApplicationServices).Wait();

            // Configure the HTTP request pipeline

            // Add cookie auth
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = ClaimsIdentityOptions.DefaultAuthenticationType,
                LoginPath = new PathString("/Account/Login")
            });

            // Add static files
            app.UseStaticFiles(new StaticFileOptions { FileSystem = new PhysicalFileSystem("wwwroot") });

            // Add MVC
            app.UseMvc(routes =>
            {
                // TODO: Move these back to attribute routes when they're available
                routes.MapRoute(null, "api/genres/menu", new { controller = "GenresApi", action = "GenreMenuList" });
                routes.MapRoute(null, "api/genres", new { controller = "GenresApi", action = "GenreList" });
                routes.MapRoute(null, "api/genres/{genreId}/albums", new { controller = "GenresApi", action = "GenreAlbums" });
                routes.MapRoute(null, "api/albums/mostPopular", new { controller = "AlbumsApi", action = "MostPopular" });
                routes.MapRoute(null, "api/albums/all", new { controller = "AlbumsApi", action = "All" });
                routes.MapRoute(null, "api/albums/{albumId}", new { controller = "AlbumsApi", action = "Details" });
                routes.MapRoute(null, "{controller}/{action}/{id?}", new { controller = "Home", action = "Index" });
            });
        }
开发者ID:BilliamBrown,项目名称:MusicStore,代码行数:64,代码来源:Startup.cs

示例11: Configure

        public void Configure(IBuilder app)
        {
            /* Adding IConfiguration as a service in the IoC to avoid instantiating Configuration again.
                 * Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, 
                 * then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
            */
            var configuration = new Configuration();
            configuration.AddJsonFile("LocalConfig.json");
            configuration.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.

            app.UseServices(services =>
            {
                // Add EF services to the services container
                services.AddEntityFramework()
                        .AddSqlServer();

                // Configure DbContext           
                services.SetupOptions<IdentityDbContextOptions>(options =>
                {
                    options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
                    options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
                    options.UseSqlServer(configuration.Get("Data:IdentityConnection:ConnectionString"));
                });

                // Add Identity services to the services container
                services.AddIdentitySqlServer<ApplicationDbContext, ApplicationUser>()
                        .AddAuthentication()
                        .SetupOptions(options =>
                        {
                            options.Password.RequireDigit = false;
                            options.Password.RequireLowercase = false;
                            options.Password.RequireUppercase = false;
                            options.Password.RequireNonLetterOrDigit = false;
                        });

                // Add MVC services to the services container
                services.AddMvc();
            });

            /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
             * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
             */
            app.UseErrorPage(ErrorPageOptions.ShowAll);

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = ClaimsIdentityOptions.DefaultAuthenticationType,
                LoginPath = new PathString("/Account/Login"),
                Notifications = new CookieAuthenticationNotifications
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(0))
                }
            });

            app.UseTwoFactorSignInCookies();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });
            });

            //Populates the MusicStore sample data
            SampleData.InitializeIdentityDatabaseAsync(app.ApplicationServices).Wait();
        }
开发者ID:ChMar,项目名称:Identity,代码行数:73,代码来源:Startup.cs

示例12: Configure

        public void Configure(IBuilder app)
        {
            /* Adding IConfiguration as a service in the IoC to avoid instantiating Configuration again.
                 * Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources, 
                 * then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
            */
            var configuration = new Configuration();
            configuration.AddJsonFile("LocalConfig.json");
            configuration.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.

	     /* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
             * Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
             */
            app.UseErrorPage(ErrorPageOptions.ShowAll);

            app.UseServices(services =>
            {
                //If this type is present - we're on mono
                var runningOnMono = Type.GetType("Mono.Runtime") != null;

                // Add EF services to the services container
                if (runningOnMono)
                {
                    services.AddEntityFramework()
                            .AddInMemoryStore();
                }
                else
                {
                    services.AddEntityFramework()
                            .AddSqlServer();
                }

                services.AddScoped<MusicStoreContext>();

                // Configure DbContext           
                services.SetupOptions<MusicStoreDbContextOptions>(options =>
                        {
                            options.DefaultAdminUserName = configuration.Get("DefaultAdminUsername");
                            options.DefaultAdminPassword = configuration.Get("DefaultAdminPassword");
                            if (runningOnMono)
                            {
                                options.UseInMemoryStore();
                            }
                            else
                            {
                                options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
                            }
                        });

                // Add Identity services to the services container
                services.AddIdentitySqlServer<MusicStoreContext, ApplicationUser>()
                        .AddAuthentication();

                // Add MVC services to the services container
                services.AddMvc();
            });

            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = ClaimsIdentityOptions.DefaultAuthenticationType,
                LoginPath = new PathString("/Account/Login"),
            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            //Populates the MusicStore sample data
            SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
        }
开发者ID:perhemmingson,项目名称:MusicStore,代码行数:83,代码来源:Startup.cs

示例13: Configure

        public void Configure(IBuilder app)
        {
            var configuration = new Configuration();
            configuration.AddJsonFile("config.json");
            configuration.AddEnvironmentVariables();

            app.UseStaticFiles();

            app.UseServices(services =>
            {
                services.AddMvc();

                var runningOnMono = Type.GetType("Mono.Runtime") != null;
                if (runningOnMono)
                {
                    services.AddEntityFramework().AddInMemoryStore();
                }
                else
                {
                    // Microsoft.Framework.DependencyInjection.SqlSer
                    services.AddEntityFramework().AddSqlServer();
                }

                services.AddScoped<BoomContext>();

                services.SetupOptions<DbContextOptions>(options =>
                {
                    if (runningOnMono)
                    {
                        options.UseInMemoryStore();
                    }
                    else
                    {
                        options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
                    }
                }
                );
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "Default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "BacklogOptionsRoute",
                    template: "backlogs/{backlogId}/options/{id?}",
                    defaults: new { controller = "BacklogOptions" });

                routes.MapRoute(
                  name: "SurveyOptionsRoute",
                  template: "surveys/{surveyId}/options/{id?}",
                  defaults: new { controller = "SurveyOptions" });

                routes.MapRoute(
                  name: "SurveyParticipantsRoute",
                  template: "surveys/{surveyId}/participants",
                  defaults: new { controller = "SurveyParticipants" });

                routes.MapRoute(
                  name: "SurveyVotesRoute",
                  template: "surveys/{surveyId}/votes",
                  defaults: new { controller = "SurveyVotes" });

                routes.MapRoute(
                    name:  "ApiRoute", 
                    template:  "{controller}/{id?}");
            });

            DbHelper.DropDatabase("BoomDb");
            DbHelper.EnsureDbCreated(app);
        }
开发者ID:izzappel,项目名称:boom,代码行数:73,代码来源:Startup.cs

示例14: Configure

 public void Configure(IBuilder app)
 {
     app.UseStaticFiles();
     app.UseWelcomePage();
 }
开发者ID:daanl,项目名称:Home,代码行数:5,代码来源:Startup.cs

示例15: Configure

        public void Configure(IBuilder app)
        {
            var configuration = new Configuration();
            configuration.AddJsonFile("localconfig.json");

            // Custom Middleware
            //app.UseMiddleware<LoggingMiddleware>();

            app.UseStaticFiles();
            app.UseErrorPage();

            app.UseServices(services =>
            {
                services.AddEntityFramework().AddSqlServer();

                services.AddScoped<MessengerDataContext>();

                services.SetupOptions<MessengerDbContextOptions>(options =>
                    {
                        options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
                    });

                // Identity
                /*
                services.AddIdentitySqlServer<MessengerDataContext, ApplicationUser>()
                    .AddAuthentication()
                    .SetupOptions(options =>
                    {
                        options.Password.RequireDigit = false;
                        options.Password.RequireLowercase = false;
                        options.Password.RequireUppercase = false;
                        options.Password.RequireNonLetterOrDigit = false;
                    });
                */

                services.AddMvc();
            });

            // Identity
            /*
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = ClaimsIdentityOptions.DefaultAuthenticationType,
                LoginPath = new PathString("/Account/Login"),
                Notifications = new CookieAuthenticationNotifications
                {
                    OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUser>(
                        validateInterval: TimeSpan.FromMinutes(0))
                }
            });

            app.UseTwoFactorSignInCookies();
            */

            app.UseMvc();

            // Custom Routing
            /*
            app.UseMvc(routes => {
                routes.MapRoute(
                    name: "Default",
                    template: "{controller=Messages}/{action=Index}/{id?}");
                });
            */
            app.UseWelcomePage();
        }
开发者ID:nateinc,项目名称:AspNetvNextDemo,代码行数:66,代码来源:Startup.cs


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