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


C# IApplicationBuilder.UseDatabaseErrorPage方法代码示例

本文整理汇总了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();
        }
开发者ID:psmyrdek,项目名称:it-learning,代码行数:48,代码来源:Startup.cs

示例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" });

            });
        }
开发者ID:jltrem,项目名称:starter,代码行数:61,代码来源:Startup.cs

示例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);
        }
开发者ID:geekpivot,项目名称:HealthClinic.biz,代码行数:34,代码来源:Startup.cs

示例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?}");
            });
        }
开发者ID:javafun,项目名称:ASPNET5Experimental,代码行数:61,代码来源:Startup.cs

示例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>();
        }
开发者ID:okusnadi,项目名称:RealTimeDataSample,代码行数:33,代码来源:Startup.cs

示例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() } });
        }
开发者ID:kbok,项目名称:OkMidnight,代码行数:28,代码来源:Startup.cs

示例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!");
            //});
        }
开发者ID:jvf00,项目名称:WebApplication1,代码行数:28,代码来源:Startup.cs

示例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();
        }
开发者ID:mickew,项目名称:InformationDisplay,代码行数:27,代码来源:Startup.cs

示例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();
        }
开发者ID:ScottKaye,项目名称:kreport-web,代码行数:35,代码来源:Startup.cs

示例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" }

                    );
            });
        }
开发者ID:sundeepkamath,项目名称:PersonalBlog,代码行数:28,代码来源:Startup.cs

示例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?}");
            });
        }
开发者ID:zhang61go,项目名称:URLForwarding,代码行数:27,代码来源:Startup.cs

示例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" });
            });
        }
开发者ID:jonfreeland,项目名称:HardCodedAuthenticationMiddleware,代码行数:35,代码来源:Startup.cs

示例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?}");
            });
        }
开发者ID:LupinIIIit,项目名称:Splendor.Web,代码行数:29,代码来源:Startup.cs

示例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>();
        }
开发者ID:XuPeiYao,项目名称:AspNetCoreTemplate,代码行数:41,代码来源:Startup.cs

示例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);
        }
开发者ID:MaherJendoubi,项目名称:Docs,代码行数:31,代码来源:Startup.cs


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