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


C# IApplicationBuilder.UseMiddleware方法代码示例

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


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

示例1: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseMiddleware<Middleware.FilterLinkProbes>();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }

            
            app.UseIISPlatformHandler();

            if (!env.IsDevelopment())
            {
                // This has to come after UseIISPlatformHandler(), otherwise
                // the request context will always think it's HTTP
                app.UseMiddleware<Middleware.EnforceHttps>();
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{action=Set}",
                    defaults: new {controller = "Home"});
            });
        }
开发者ID:vsliouniaev,项目名称:pass-cache-2,代码行数:34,代码来源:Startup.cs

示例2: Configure

        public void Configure(IApplicationBuilder app)
        {
            if (_principal1 != null)
            {
                app.UseMiddleware<TestAuthenticationMiddleware>(new TestAuthenticationOptions
                {
                    AuthenticationScheme = "scheme1",
                    User = _principal1,

                    AutomaticAuthenticate = _automaticAuthenticate
                });
            }

            if (_principal2 != null)
            {
                app.UseMiddleware<TestAuthenticationMiddleware>(new TestAuthenticationOptions
                {
                    AuthenticationScheme = "scheme2",
                    User = _principal2,

                    AutomaticAuthenticate = _automaticAuthenticate
                });
            }

            app.AllowScopes(_scopeOptions);

            app.Run(ctx =>
            {
                ctx.Response.StatusCode = 200;
                return Task.FromResult(0);
            });
        }
开发者ID:NetChris,项目名称:IdentityModel.AspNet.ScopeValidation,代码行数:32,代码来源:MultipleAuthenticationStartup.cs

示例3: Configure

        public override void Configure(IApplicationBuilder builder, IRouteBuilder routes, IServiceProvider serviceProvider)
        {

            routes.MapAreaRoute(
                name: "Home",
                area: "Orchard.Demo",
                template: "Home/Index",
                controller: "Home",
                action: "Index"
            );

            routes.MapAreaRoute(
                name: "Display",
                area: "Orchard.Demo",
                template: "Home/Display/{id}",
                controller: "Home",
                action: "Display"
            );

            routes.MapAreaRoute(
                name: "Error",
                area: "Orchard.Demo",
                template: "Home/IndexError",
                controller: "Home",
                action: "IndexError"
            );

            builder.UseMiddleware<NonBlockingMiddleware>();
            builder.UseMiddleware<BlockingMiddleware>();
        }
开发者ID:jchenga,项目名称:Orchard2,代码行数:30,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseMiddleware(typeof(MyMiddleware));
            app.UseMiddleware(typeof(MyMiddleware));

            app.Run(async context =>
                await context.Response.WriteAsync("---------- Done\r\n"));
        }
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-Entropy-aspnet,代码行数:8,代码来源:Startup.cs

示例5: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseMiddleware<VersionHeaderMiddleware>();
     app.UseMiddleware<SuperstitiousMiddleware>();
     app.Run(async ctx => 
     {
         ctx.Response.StatusCode = 200;
         await ctx.Response.WriteAsync("Hello world!");
     });
 }
开发者ID:ehvattum,项目名称:aspnet-5-samples,代码行数:10,代码来源:Startup.cs

示例6: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseRequestServices(DefineServices().BuildServiceProvider());

            app.UseMiddleware(typeof(MyMiddleware));
            app.UseMiddleware(typeof(MyMiddleware));

            app.Run(async context =>
                await context.Response.WriteAsync("---------- Done\r\n"));
        }
开发者ID:Tragetaschen,项目名称:Entropy,代码行数:10,代码来源:Startup.cs

示例7: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseMiddleware<IISIntegrationHackMiddlerware>();
            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            app.UseMiddleware<IpBlockerMiddleware>();
            app.UseMiddleware<ForceHttpsMiddleware>();
            app.UseMiddleware<ForceDomainMiddleware>();

            app.UseStaticFiles();
            app.UseIdentity();
            app.UseSession();

            var facebookAppId = Configuration["Skimur:Authentication:Facebook:AppId"];
            var facebookAppSecret = Configuration["Skimur:Authentication:Facebook:AppSecret"];
            if (!string.IsNullOrEmpty(facebookAppId) && !string.IsNullOrEmpty(facebookAppSecret))
            {
                app.UseFacebookAuthentication(options =>
                {
                    options.AppId = facebookAppId;
                    options.AppSecret = facebookAppSecret;
                });
            }

            var googleClientId = Configuration["Skimur:Authentication:Google:ClientId"];
            var googleClientSecret = Configuration["Skimur:Authentication:Google:ClientSecret"];
            if (!string.IsNullOrEmpty(googleClientId) && !string.IsNullOrEmpty(googleClientSecret))
            {
                app.UseGoogleAuthentication(options =>
                {
                    options.ClientId = googleClientId;
                    options.ClientSecret = googleClientSecret;
                    options.Scope.Add("https://www.googleapis.com/auth/plus.profile.emails.read");
                });
            }
            
            app.UseMvc(routes =>
            {
                Routes.Register(routes);
            });
        }
开发者ID:skimur,项目名称:skimur,代码行数:55,代码来源:Startup.cs

示例8: Configure

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


            app.UseMiddleware<AuthorizeBasicMiddleware>("Interactive");
            app.UseMiddleware<AuthorizeBasicMiddleware>("Api");
            app.UseMiddleware<ErrorReporterMiddleware>();

            app.UseMvcWithDefaultRoute();
        }
开发者ID:phinq19,项目名称:git_example,代码行数:11,代码来源:Startup.cs

示例9: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseMiddleware<HelloMiddleware>();
            app.UseMiddleware<WorldMiddleware>();

            app.Use(next => async context =>
            {
                await context.Response.WriteAsync("12345\r\n");

                await next(context);
            });
        }
开发者ID:RickyLin,项目名称:Demos,代码行数:12,代码来源:Startup.cs

示例10: CreateHost

        public static IOrchardHost CreateHost(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddProvider(new TestLoggerProvider());

            app.UseMiddleware<OrchardContainerMiddleware>();
            app.UseMiddleware<OrchardShellHostMiddleware>();

            // Think this needs to be inserted in a different part of the pipeline, possibly
            // when DI is created for the shell
            app.UseMiddleware<OrchardRouterMiddleware>();

            return app.ApplicationServices.GetService<IOrchardHost>();
        }
开发者ID:jp311,项目名称:Brochard,代码行数:13,代码来源:OrchardStarter.cs

示例11: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseIISPlatformHandler();
            app.UseMiddleware<LogResponseMiddleware>();
            app.UseMiddleware<LogRequestMiddleware>();            

            app.UseStaticFiles();

            app.UseMvc();
        }
开发者ID:sulhome,项目名称:log-request-response-middleware,代码行数:13,代码来源:Startup.cs

示例12: 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

示例13: Configure

 public void Configure(IApplicationBuilder app)
 {
     var listener = app.ServerFeatures.Get<WebListener>();
     if (listener != null)
     {
         listener.AuthenticationManager.AuthenticationSchemes = AuthenticationSchemes.NTLM;
     } 
     else 
     {
         app.UseMiddleware<NtlmAuthenticationMiddleware>();
         app.UseMiddleware<HelloWorldMiddleware>();    
     }
     
     app.Run(context => context.Response.WriteAsync("test"));
 }
开发者ID:revlucio,项目名称:Revlucio.NtlmAuthentication,代码行数:15,代码来源:Startup.cs

示例14: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(LogLevel.Debug);
			
            app.Map(
                new PathString("/onboarding"),
                branch => branch.Run(async ctx =>
                {
                    await ctx.Response.WriteAsync("Onboarding");
                })
            );

            app.UseMultitenancy<AppTenant>();

            app.Use(async (ctx, next) =>
            {
                if (ctx.GetTenant<AppTenant>().Name == "Default")
                {
                    ctx.Response.Redirect("/onboarding");
                } else
                {
                    await next();
                }
            });

            app.UseMiddleware<LogTenantMiddleware>();
        }
开发者ID:rdefreitas,项目名称:saaskit,代码行数:28,代码来源:Startup.cs

示例15: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseStaticFiles(new StaticFileOptions()
            {
                FileProvider = new PhysicalFileProvider(
                    Path.Combine(Directory.GetCurrentDirectory(), @"Pictures")),
                RequestPath = new PathString("/Pictures")
            });

            app.UseMiddleware<CatifyMiddleware>();

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


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