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


C# IApplicationBuilder.UseServices方法代码示例

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


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

示例1: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseServices(services =>
            {
                // We add MVC here instead of in ConfigureServices.
                services.AddMvc();

                // Create the Autofac container builder.
                var builder = new ContainerBuilder();

                // Add any Autofac modules or registrations.
                builder.RegisterModule(new AutofacModule());

                // Populate the services.
                builder.Populate(services);

                // Build the container.
                var container = builder.Build();

                // Resolve and return the service provider.
                return container.Resolve<IServiceProvider>();
            });

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

示例2: Configure

        public void Configure(IApplicationBuilder app)
        {
            // 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 and configure DbContext
                services.ConfigureDataContext(configuration);

                // Register MyShuttle dependencies
                services.ConfigureDependencies();


                //Add Identity services to the services container
                services.AddDefaultIdentity<MyShuttleContext, ApplicationUser, IdentityRole>(configuration);
                services.ConfigureCookieAuthentication(options =>
                {
                    options.LoginPath = new Microsoft.AspNet.Http.PathString("/Carrier/Login");
                });


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

                services
                    .AddSignalR(options =>
                    {
                        options.Hubs.EnableDetailedErrors = true;
                    });
            });

            // Enable Browser Link support
            app.UseBrowserLink();

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

            app.ConfigureSecurity();

            //Configure SignalR
            app.UseSignalR();

            // Add cookie-based authentication to the request pipeline

            // Add MVC to the request pipeline
            app.ConfigureRoutes();

            MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();

        }
开发者ID:sriramdasbalaji,项目名称:My-Shuttle-Biz,代码行数:59,代码来源:Startup.cs

示例3: Configure

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

            // Set up application services
            app.UseServices(services =>
            {
                services.AddAssembly(this);

                // 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.AddIdentitySqlServer<ApplicationDbContext, ApplicationUser>()
                //    .AddAuthentication();

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

                services.AddTransient(typeof(IService1), typeof(Service1));
            });

            // Enable Browser Link support
            //app.UseBrowserLink();

            // 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?}");
            });
        }
开发者ID:david-driscoll,项目名称:DependencyInjection.Annotations,代码行数:58,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseErrorPage();

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

            app.UseMvc();

            app.UseStaticFiles();
        }
开发者ID:HeathWillCode,项目名称:MVC6UnitTests,代码行数:13,代码来源:Startup.cs

示例5: CreateHostContainer

        private static void CreateHostContainer(IApplicationBuilder app) {
            app.UseServices(services => {
                services.AddSingleton<IHostEnvironment, DefaultHostEnvironment>();
                services.AddSingleton<IAppDataFolderRoot, AppDataFolderRoot>();

                services.AddSingleton<IWebSiteFolder, WebSiteFolder>();
                services.AddSingleton<IAppDataFolder, AppDataFolder>();
                services.AddSingleton<IVirtualPathProvider, DefaultVirtualPathProvider>();

                services.AddSingleton<ILoggerFactory, TestLoggerFactory>();

                // Caching - Move out?
                services.AddInstance<ICacheContextAccessor>(new CacheContextAccessor());
                services.AddSingleton<ICache, Cache>();

                services.AddTransient<IOrchardHost, DefaultOrchardHost>();
                {
                    services.AddSingleton<IShellSettingsManager, ShellSettingsManager>();

                    services.AddSingleton<IShellContextFactory, ShellContextFactory>();
                    {
                        services.AddSingleton<ICompositionStrategy, CompositionStrategy>();
                        {
                            services.AddSingleton<IOrchardLibraryManager, OrchardLibraryManager>();
                            services.AddSingleton<IExtensionManager, ExtensionManager>();
                            {
                                services.AddSingleton<IExtensionHarvester, ExtensionHarvester>();
                                services.AddSingleton<IExtensionFolders, ModuleFolders>();
                                services.AddSingleton<IExtensionFolders, CoreModuleFolders>();

                                services.AddSingleton<IExtensionLoader, DefaultExtensionLoader>();
                            }
                        }

                        services.AddSingleton<IShellContainerFactory, ShellContainerFactory>();
                    }
                }
                
                services.AddTransient<IOrchardShellHost, DefaultOrchardShellHost>();
                
                services.AddInstance<IServiceManifest>(new ServiceManifest(services));
            });
            
            app.UseMiddleware<OrchardContainerMiddleware>();
            app.UseMiddleware<OrchardShellHostMiddleware>();

            // Think this needs to be inserted in a different part of the pipeline, possibly
            // dhen DI is created for the shell
            app.UseMiddleware<OrchardRouterMiddleware>();
        }
开发者ID:jefth,项目名称:OrchardNoCMS,代码行数:50,代码来源:OrchardStarter.cs

示例6: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseErrorPage();
            app.UseFileServer();

            app.UseServices(services =>
            {
                services.AddMvc();
                services.AddScoped<IProfileLinkManager, ProfileLinkManager>();
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute("defaultRoute", "{controller=Home}/{action=Index}");
            });
        }
开发者ID:boro2g,项目名称:AspNetVNextSamples,代码行数:16,代码来源:Startup.cs

示例7: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseServices(services =>
            {
                services.AddSignalR(options =>
                {
                    options.Hubs.EnableDetailedErrors = true;
                    // options.Hubs.RequireAuthentication();
                });
            });

            //app.UseFileServer();

            //app.UseSignalR<RawConnection>("/raw-connection");
            app.UseSignalR();
        }
开发者ID:wertzui,项目名称:HomeController,代码行数:16,代码来源:Startup.cs

示例8: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseServices(services =>
            {
                services.AddMvc();
            });
            app.UseMvc(routes =>
            {
                routes.MapRoute(name: "default",
                    template: "Project_Readme.html");
            });

            //app.Run(async (context) =>
            //{
            //    await context.Response.WriteAsync("Hello World!");
            //});
        }
开发者ID:AntonZinchenko,项目名称:CookBook,代码行数:17,代码来源:Startup.cs

示例9: Configure

        public void Configure(IApplicationBuilder app)
        {
            // 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 MVC services to the services container
                services.AddMvc();
            });

            // Enable Browser Link support
            app.UseBrowserLink();

            // 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:LeoLcy,项目名称:MVC6Recipes,代码行数:43,代码来源:Startup.cs

示例10: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseStaticFiles();

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

            // 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:bbgunmaster,项目名称:koan-2,代码行数:22,代码来源:Startup.cs

示例11: Configure

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

        app.Use(async (context, next) => 
        {
            Console.WriteLine(context.Request.Path);

            try
            {
                await next();
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex);
            }
        });

        app.UseMvc();
    }
开发者ID:jbuiss0n,项目名称:HelloWorldVNext,代码行数:23,代码来源:Startup.cs


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