本文整理汇总了C#中IApplicationBuilder.UseDatabaseErrorPage方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseDatabaseErrorPage方法的具体用法?C# IApplicationBuilder.UseDatabaseErrorPage怎么用?C# IApplicationBuilder.UseDatabaseErrorPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseDatabaseErrorPage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
MappingsProvider.ConfigureMappings();
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
try
{
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
//TODO better production release scenario
serviceScope.ServiceProvider.GetService<AppDbContext>().Database.Migrate();
}
}
catch
{
}
}
app.UseStatusCodePagesWithRedirects("~/Home/Error/{0}");
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
app.UseSession();
app.EnsureRolesCreated();
var staticProvidersConfigurator = app.ApplicationServices.GetService<IStaticProvidersConfigurator>();
staticProvidersConfigurator.Init();
app.UseCookieAuthentication((p) => new CookieAuthenticationOptions
{
LoginPath = "/Account/Login"
});
app.UseMvc();
}
示例2: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseErrorHandler("App/Home/Error");
}
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
// app.UseFacebookAuthentication();
// app.UseGoogleAuthentication();
// app.UseMicrosoftAccountAuthentication();
// app.UseTwitterAuthentication();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "home",
template: "home",
defaults: new { area = "app", controller = "home", action = "home" });
routes.MapRoute(
name: "dashboard",
template: "dash",
defaults: new { area = "app", controller = "home", action = "dash" });
routes.MapRoute(
name: "administration",
template: "admin",
defaults: new { area = "app", controller = "home", action = "admin" });
routes.MapRoute(
name: "default",
template: "{area}/{controller}/{action}",
defaults: new { area = "app", controller = "home", action = "index" });
});
}
示例3: Configure
// Configure is called after ConfigureServices is called.
public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, MyHealthDataInitializer dataInitializer)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage(options => options.EnableAll());
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseExceptionHandler("/Home/Error");
}
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.ConfigureRoutes();
await dataInitializer.InitializeDatabaseAsync(app.ApplicationServices, Configuration);
}
示例4: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory, ApplicationDbContext context)
{
// Seeding data as EF7 doesn't support seeding data
if (context.Courses.FirstOrDefault() == null)
{
context.Courses.Add(new Course { Title = "Basics of ASP.NET 5", Author = "Mahesh", Duration = 4 });
context.Courses.Add(new Course { Title = "Getting started with Grunt", Author = "Ravi", Duration = 3 });
context.Courses.Add(new Course { Title = "What's new in Angular 1.4", Author = "Ravi", Duration = 4 });
context.Courses.Add(new Course { Title = "Imagining JavaScript in ES6", Author = "Suprotim", Duration = 4 });
context.Courses.Add(new Course { Title = "C# Best Practices", Author = "Craig", Duration = 3 });
context.SaveChanges();
}
// Configure the HTTP request pipeline.
// Add the console logger.
loggerfactory.AddConsole(minLevel: LogLevel.Warning);
// Add the following to the request pipeline only in development environment.
if (env.IsEnvironment("Development"))
{
app.UseBrowserLink();
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
}
//app.UseDirectoryBrowser();
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
// app.UseFacebookAuthentication();
// app.UseGoogleAuthentication();
// app.UseMicrosoftAccountAuthentication();
// app.UseTwitterAuthentication();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
// Uncomment the following line to add a route for porting Web API 2 controllers.
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
});
}
示例5: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseErrorHandler("/index.html");
}
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add SignalR to the request pipeline.
app.UseSignalR();
// Add MVC to the request pipeline.
app.UseMvc();
app.ApplicationServices.GetRequiredService<PerformanceGenerator>();
}
示例6: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseStaticFiles();
app.ApplicationServices.GetRequiredService<OkMidnightDbContext>().EnsureSeedData();
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseIdentity();
app.UseMicrosoftAccountAuthentication(new MicrosoftAccountOptions
{
ClientId = _configuration["Authentication:Microsoft:ClientId"],
ClientSecret = _configuration["Authentication:Microsoft:ClientSecret"]
});
app.UseMvc(routes => {
routes.MapRoute("home", "{action=Index}/{id?}/{name?}", new { controller = "Home" });
routes.MapRoute("admin", "admin/{controller=Categories}/{action=Index}/{id?}");
routes.MapRoute("account", "account/{action=Index}", new { controller = "Account" });
routes.MapRoute("picker", "picker/{name}", new { controller = "Picker", action = "Index" });
});
app.UseHangfireServer();
app.UseHangfireDashboard("/hangfire", new DashboardOptions { Authorization = new[] { new LoggedUserAuthorizationFilter() } });
}
示例7: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
}
// Serve the default file, if present.
app.UseDefaultFiles();
// Add static files to the request pipeline.
app.UseStaticFiles();
//app.Run(async (context) =>
//{
// await context.Response.WriteAsync("Hello World!");
//});
}
示例8: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage(options =>
{
options.EnableAll();
});
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseExceptionHandler("/Home/Error");
}
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseIdentity();
app.UseMvc();
ApplicationDbContext.InitializeDatabaseAsync(app.ApplicationServices).Wait();
}
示例9: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
app.UseErrorPage();
}
else
{
//TODO: custom error page
//app.UseErrorHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseSession();
app.Use((context, next) =>
{
context.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
context.Response.Headers.Add("Access-Control-Allow-Headers", new[] { "*" });
context.Response.Headers.Add("Access-Control-Allow-Methods", new[] { "*" });
return next();
});
app.UseCookieAuthentication(options =>
{
options.AutomaticAuthentication = true;
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
app.UseSignalR();
}
示例10: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
{
serviceScope.ServiceProvider.GetService<BlogContext>().Database.Migrate();
serviceScope.ServiceProvider.GetService<BlogContext>().Database.EnsureCreated();
serviceScope.ServiceProvider.GetService<BlogContext>().EnsureSeedData();
}
}
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseMvc(config => {
config.MapRoute(
name: "Default",
template: "{controller}/{action}/{id?}",
defaults: new { controller="Blog", action="Posts" }
);
});
}
示例11: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseCookieAuthentication(options =>
{
options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.LoginPath = new PathString("/Admin/Login/");
options.AccessDeniedPath = new PathString("/Admin/");
options.AutomaticAuthenticate = true;
options.AutomaticChallenge = true;
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例12: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
loggerfactory.AddConsole(minLevel: LogLevel.Warning);
if (env.IsEnvironment("Development")) {
////app.UseBrowserLink();
app.UseErrorPage(new ErrorPageOptions { SourceCodeLineCount = 10 });
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
} else {
app.UseErrorHandler("/Home/Error");
}
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
if (env.IsEnvironment("Development")) {
app.UseHardCodedAuthentication();
} else {
// Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
// app.UseFacebookAuthentication();
// app.UseGoogleAuthentication();
// app.UseMicrosoftAccountAuthentication();
// app.UseTwitterAuthentication();
}
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
}
示例13: 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.UseDatabaseErrorPage();
app.UseBrowserLink();
} else {
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseIdentity();
// Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes => {
routes.MapRoute(name: "areaRoute",
template: "{area:exists}/{controller}/{action}/{id?}",
defaults: new { controller = "Dashboard", action = "Index" });
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例14: Configure
/// <summary>
/// 設定AspNetCore
/// </summary>
/// <param name="app">應用程式建構器</param>
/// <param name="env">環境變數</param>
/// <param name="loggerFactory">記錄檔處理類別</param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
#region Development Configure
//加入記錄主控台設定
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
//除錯模式
loggerFactory.AddDebug();
#endregion
#region StaticFiles Configure
//設定預設檔案
ConfigureDefaultFiles(app);
if (!env.IsDevelopment()) {//是否為開發模式
app.UseDeveloperExceptionPage();//使用開發模式錯誤頁面
app.UseDatabaseErrorPage();//使用資料庫錯誤頁面
app.UseBrowserLink();//使用瀏覽器連結
} else {
ConfigureErrorPages(app, env);//設定錯誤頁面對應
}
//使用靜態檔案
app.UseStaticFiles();
#endregion
//使用Session
app.UseSession();
//使用MVC服務,並且載入預設路由設定
app.UseMvc(ConfigureMvcRoute);
//WebSocket設定
app.UseWebSockets<TestChatHanlder>();
}
示例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.UseDatabaseErrorPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseIdentity();
#region snippet_1
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endregion
SeedData.Initialize(app.ApplicationServices);
}