本文整理汇总了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"});
});
}
示例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>();
}
示例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"));
}
示例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!");
});
}
示例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"));
}
示例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);
});
}
示例8: Configure
public void Configure(IApplicationBuilder app)
{
app.UseCultureReplacer();
app.UseMiddleware<AuthorizeBasicMiddleware>("Interactive");
app.UseMiddleware<AuthorizeBasicMiddleware>("Api");
app.UseMiddleware<ErrorReporterMiddleware>();
app.UseMvcWithDefaultRoute();
}
示例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);
});
}
示例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>();
}
示例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();
}
示例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>();
}
示例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"));
}
示例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>();
}
示例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?}");
});
}