本文整理汇总了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!");
});
}
示例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();
}
示例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");
});
}
示例4: Configure
public void Configure(IApplicationBuilder app)
{
var OverrideMiddlewareOptions = new OverrideHeaderMiddlewareOptions(true);
OverrideMiddlewareOptions.XForwardProtoEnabled = false;
app.UseOverrideHeaders(OverrideMiddlewareOptions);
}
示例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);
}