本文整理汇总了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" });
});
}
示例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();
}
示例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?}");
});
}
示例4: Configure
public void Configure(IApplicationBuilder app)
{
app.UseErrorPage();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseMvc();
app.UseStaticFiles();
}
示例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>();
}
示例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}");
});
}
示例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();
}
示例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!");
//});
}
示例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?}");
});
}
示例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?}");
});
}
示例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();
}