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


C# IApplicationBuilder.UseOverrideHeaders方法代码示例

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


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

示例1: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseIISPlatformHandler();
     app.UseOverrideHeaders(new OverrideHeaderOptions
     {
         ForwardedOptions = ForwardedHeaders.All
     });
     
     app.Run(context =>
     {
         return context.Response.WriteAsync($"Hello World!");
     });
 }
开发者ID:chrisschuyler,项目名称:dotnetcli-aspnetcore,代码行数:13,代码来源:Startup.cs

示例2: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = env.IsDevelopment() ? LogLevel.Debug : LogLevel.Warning;
            loggerFactory.AddConsole(LogLevel.Debug);
            loggerFactory.AddDebug(LogLevel.Debug);

            app.UseOverrideHeaders(new OverrideHeaderMiddlewareOptions { ForwardedOptions = ForwardedHeaders.All });

            app.UseDeveloperExceptionPage();

            // Configure the HTTP request pipeline.
            app.UseMiddleware(typeof(ApiV2Middleware));
            app.UseDefaultFiles().UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc();
        }
开发者ID:azyobuzin,项目名称:img.azyobuzi.net,代码行数:18,代码来源:Startup.cs

示例3: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            app.UseIISPlatformHandler();
            app.UseOverrideHeaders(new OverrideHeaderOptions
            {
                ForwardedOptions = ForwardedHeaders.All
            });
            app.UseHttpMethodOverride();

            app.Run(async (context) =>
            {
                foreach (var header in context.Request.Headers)
                {
                    await context.Response.WriteAsync($"{header.Key}: {header.Value}\r\n");
                }
                await context.Response.WriteAsync($"Method: {context.Request.Method}\r\n");
                await context.Response.WriteAsync($"Scheme: {context.Request.Scheme}\r\n");
                await context.Response.WriteAsync($"RemoteIP: {context.Connection.RemoteIpAddress}\r\n");
                await context.Response.WriteAsync($"RemotePort: {context.Connection.RemotePort}\r\n");
            });
        }
开发者ID:leloulight,项目名称:BasicMiddleware,代码行数:22,代码来源:Startup.cs

示例4: Configure

 public void Configure(IApplicationBuilder app)
 {
     var OverrideMiddlewareOptions = new OverrideHeaderMiddlewareOptions(true);
     OverrideMiddlewareOptions.XForwardProtoEnabled = false;
     app.UseOverrideHeaders(OverrideMiddlewareOptions);
 }
开发者ID:mikaelm12,项目名称:OverrideHeaderMiddleware,代码行数:6,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app)
        {
            var factory = app.ApplicationServices.GetRequiredService<ILoggerFactory>();
            factory.AddConsole();
            factory.AddDebug();

            app.UseIISPlatformHandler(options => {
                options.FlowWindowsAuthentication = false;
            });

            app.UseOverrideHeaders(options => {
                options.ForwardedOptions = ForwardedHeaders.All;
            });
            app.UseStaticFiles();

            // Add a middleware used to validate access
            // tokens and protect the API endpoints.
            app.UseOAuthValidation();
            
            // Alternatively, you can also use the introspection middleware.
            // Using it is recommended if your resource server is in a
            // different application/separated from the authorization server.
            // 
            // app.UseOAuthIntrospection(options => {
            //     options.AutomaticAuthenticate = true;
            //     options.AutomaticChallenge = true;
            //     options.Authority = "http://localhost:54540/";
            //     options.Audience = "resource_server";
            //     options.ClientId = "resource_server";
            //     options.ClientSecret = "875sqd4s5d748z78z7ds1ff8zz8814ff88ed8ea4z4zzd";
            // });

            app.UseIdentity();
            //var settings = app.ApplicationServices.GetService<AppSettings>();
            //app.UseGoogleAuthentication(new GoogleOptions() {
            //    ClientId = settings.OAuth.Google.ClientId,
            //    ClientSecret = settings.OAuth.Google.ClientSecret
            //});

            //app.UseTwitterAuthentication(new TwitterOptions()
            //{
            //    ConsumerKey = settings.OAuth.Twitter.ClientId,
            //    ConsumerSecret = settings.OAuth.Twitter.ClientSecret
            //});
            
            // Note: OpenIddict must be added after
            // ASP.NET Identity and the external providers.
            app.UseOpenIddict(options =>
            {
                // You can customize the default Content Security Policy (CSP) by calling UseNWebsec explicitly.
                // This can be useful to allow your HTML views to reference remote scripts/images/styles.
                options.UseNWebsec(directives =>
                {
                    directives.DefaultSources(directive => directive.Self())
                        .ImageSources(directive => directive.Self().CustomSources("*"))
                        .ScriptSources(directive => directive
                            .Self()
                            .UnsafeInline()
                            .CustomSources("https://my.custom.url"))
                        .StyleSources(directive => directive.Self().UnsafeInline());
                });
            });

            app.UseMvcWithDefaultRoute();
          //  CreateClients(app);
       
        }
开发者ID:robinchesterman,项目名称:canvassAPI,代码行数:67,代码来源:Startup.cs


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