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


C# IBuilder.UseFileServer方法代码示例

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


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

示例1: Configure

    public void Configure(IBuilder app)
    {
        app.UseServices(services =>
        {
            /* 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.
            services.AddInstance<IConfiguration>(configuration);

            //Add all MVC related services to IoC.
            services.AddMvc();

            /*Add all EF related services to IoC.*/
            services.AddEntityFramework().AddSqlServer();
            services.AddTransient<MusicStoreContext>();

            //Add all Identity related services to IoC. 
            services.AddTransient<DbContext, ApplicationDbContext>();
            services.AddIdentity<ApplicationUser, IdentityRole>(s =>
            {
                s.AddEntity();
            });
            services.AddTransient<SignInManager<ApplicationUser>>();
        });


        /* 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);

        //Serves static files in the application.
        app.UseFileServer();

        app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
            LoginPath = new PathString("/Account/Login"),
        });

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                null,
                "{controller}/{action}",
                new { controller = "Home", action = "Index" });
        });

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

        //Creates a Store manager user who can manage the store.
        CreateAdminUser(app.ApplicationServices).Wait();
    }
开发者ID:kaushalp,项目名称:MusicStore,代码行数:59,代码来源:Startup.cs

示例2: ConfigurePK

 private void ConfigurePK(IBuilder builder)
 {
     builder.UseFileServer(new FileServerOptions()
     {
         EnableDirectoryBrowsing = true,
         FileSystem = new PhysicalFileSystem(@"c:\temp")
     });
 }
开发者ID:jizhonglee,项目名称:StaticFiles,代码行数:8,代码来源:Startup.cs

示例3: Configure

    public void Configure(IBuilder app)
    {
        /* 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 =>
            {
                //Add all MVC related services to IoC.
                services.AddMvc();

                //Add all SignalR related services to IoC.
                services.AddSignalR();
            });

            //Configure SignalR
            app.UseSignalR();

            //Serves static files in the application.
            app.UseFileServer();

            //Configure WebFx
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    null,
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    null,
                    "api/{controller}/{action}",
                    new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    null,
                    "api/{controller}",
                    new { controller = "Home" });
            });
    }
开发者ID:kaushalp,项目名称:BugTracker,代码行数:41,代码来源:Startup.cs

示例4: Configuration

        public void Configuration(IBuilder app)
        {
            var serviceProvider = new ServiceCollection()
                     .Add(MvcServices.GetDefaultServices())
                     .Add(SignalRServices.GetServices())
                     .BuildServiceProvider(app.ServiceProvider);

            app.UseContainer(serviceProvider);

            //Configure static files
            app.UseFileServer();

            //Configure WebFx
            var routes = new RouteCollection()
            {
                DefaultHandler = new MvcApplication(serviceProvider),
            };

            routes.MapRoute(
                "{controller}/{action}",
                new { controller = "Home", action = "Index" });

            routes.MapRoute(
                "api/{controller}/{action}",
                new { controller = "Home", action = "Index" });

            routes.MapRoute(
                "api/{controller}",
                new { controller = "Home" });

            //Configure MVC
            app.UseRouter(routes);

            //Configure SignalR
            app.MapSignalR();
        }
开发者ID:jvlstudio,项目名称:BugTracker,代码行数:36,代码来源:Startup.cs

示例5: Configure

        public void Configure(IBuilder app)
        {
            app.UseFileServer();
#if NET45
            var configuration = new Configuration()
                                    .AddJsonFile(@"App_Data\config.json")
                                    .AddEnvironmentVariables();

            string diSystem;

            if (configuration.TryGet("DependencyInjection", out diSystem) && 
                diSystem.Equals("AutoFac", StringComparison.OrdinalIgnoreCase))
            {
                app.UseMiddleware<MonitoringMiddlware>();

                var services = new ServiceCollection();

                services.AddMvc();
                services.AddSingleton<PassThroughAttribute>();
                services.AddSingleton<UserNameService>();
                services.AddTransient<ITestService, TestService>();                
                services.Add(OptionsServices.GetDefaultServices());

                // Create the autofac container 
                ContainerBuilder builder = new ContainerBuilder();

                // Create the container and use the default application services as a fallback 
                AutofacRegistration.Populate(
                    builder,
                    services,
                    fallbackServiceProvider: app.ApplicationServices);

                builder.RegisterModule<MonitoringModule>();

                IContainer container = builder.Build();

                app.UseServices(container.Resolve<IServiceProvider>());
            }
            else
#endif
            {
                app.UseServices(services =>
                {
                    services.AddMvc();
                    services.AddSingleton<PassThroughAttribute>();
                    services.AddSingleton<UserNameService>();
                    services.AddTransient<ITestService, TestService>();
                });
            }

            app.UseMvc(routes =>
            {
                routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");

                routes.MapRoute(
                    "controllerActionRoute",
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    "controllerRoute",
                    "{controller}",
                    new { controller = "Home" });
            });
        }
开发者ID:Nakro,项目名称:Mvc,代码行数:65,代码来源:Startup.cs


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