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


C# IApplicationBuilder.UseErrorHandler方法代码示例

本文整理汇总了C#中IApplicationBuilder.UseErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseErrorHandler方法的具体用法?C# IApplicationBuilder.UseErrorHandler怎么用?C# IApplicationBuilder.UseErrorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IApplicationBuilder的用法示例。


在下文中一共展示了IApplicationBuilder.UseErrorHandler方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseErrorHandler();
            app.UsePlainText();
            app.UseJson();

            if (StartupOptions.EnableDbTests)
            {
                app.UseSingleQueryRaw(StartupOptions.ConnectionString);
                app.UseSingleQueryDapper(StartupOptions.ConnectionString);
                app.UseSingleQueryEf();

                app.UseMultipleQueriesRaw(StartupOptions.ConnectionString);
                app.UseMultipleQueriesDapper(StartupOptions.ConnectionString);
                app.UseMultipleQueriesEf();

                app.UseFortunesRaw(StartupOptions.ConnectionString);
                app.UseFortunesDapper(StartupOptions.ConnectionString);
                app.UseFortunesEf();

                var dbContext = (ApplicationDbContext)app.ApplicationServices.GetService(typeof(ApplicationDbContext));
                var seeder = (ApplicationDbSeeder)app.ApplicationServices.GetService(typeof(ApplicationDbSeeder));
                if (!seeder.Seed(dbContext))
                {
                    Environment.Exit(1);
                }
                Console.WriteLine("Database tests enabled");
            }

            app.UseMvc();

            app.Run(context => context.Response.WriteAsync("Try /plaintext instead"));
        }
开发者ID:mgravell,项目名称:benchmarks,代码行数:33,代码来源: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);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                // Uncomment the following line to add a route for porting Web API 2 controllers.
                // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
            });
        }
开发者ID:nkkn1008,项目名称:vs-soul-github,代码行数:35,代码来源:Startup.cs

示例3: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
        {
            // Configure the HTTP request pipeline.

            // Add the console logger.
            loggerfactory.AddConsole(minLevel: LogLevel.Verbose);

            // Add the following to the request pipeline only in development environment.
            if (env.IsEnvironment("Development"))
            {
                app.UseBrowserLink();
                app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
            SampleData.Initialize(app.ApplicationServices);
        }
开发者ID:bigfont,项目名称:Docs,代码行数:33,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            Log.Logger = new LoggerConfiguration()
                .MinimumLevel.Information()
            #if DNXCORE50
                            .WriteTo.TextWriter(Console.Out)
            #else
                            .WriteTo.Trace()
                .WriteTo.RollingFile("log-{Date}.txt")
            #endif
            .CreateLogger();

            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();
            loggerFactory.AddSerilog();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                app.UseErrorHandler("/Home/Error");
            }

            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:Flank2k2,项目名称:MVC6Experiment,代码行数:34,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseStaticFiles();

            if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
            {
                app.UseBrowserLink();
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            app.UseMvcWithDefaultRoute();

            //Long-hand way to map the default route

            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "default",
            //        template: "{controller=Home}/{action=Index}/{id?}");
            //});
        }
开发者ID:peterblazejewicz,项目名称:ASP.NET5Demos,代码行数:26,代码来源:Startup.cs

示例6: 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

示例7: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.MinimumLevel = LogLevel.Information;
            loggerFactory.AddConsole();

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseErrorPage();
            }
            else
            {
                app.UseErrorHandler("/Home/Error");
            }

            // Add static files to the request pipeline.
            app.UseStaticFiles();

            // Add MVC to the request pipeline.
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

            });
        }
开发者ID:johnciliberti,项目名称:MVC6Recipes,代码行数:29,代码来源:Startup.cs

示例8: Configure

        public void Configure(IApplicationBuilder app)
        {
            var password = config["password"];

            if (config["RecreateDatabase"] == "true")
            {
                var context = app.ApplicationServices.GetService<Models.BlogDataContext>();
                context.Database.EnsureDeleted();
                System.Threading.Thread.Sleep(2000);
                context.Database.EnsureCreated();
            }

            app.UseIdentity();

            if (config["debug"] == "true")
            {
                app.UseErrorPage();
                app.UseRuntimeInfoPage();
            }
            else
            {
                app.UseErrorHandler("/home/error");
            }

            app.UseMvc(routes => routes.MapRoute(
                "Default", "{controller=Home}/{action=Index}/{id?}"));

            app.UseFileServer();
        }
开发者ID:Codenator81,项目名称:UpAndRunningWithAspNet5,代码行数:29,代码来源:Startup.cs

示例9: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseErrorHandler(a =>
            {
                a.UseMiddleware<ErrorMiddleware>();
            });

            app.UseWelcomePage("/welcome");
            app.UseRuntimeInfoPage("/runtimeinfo");


            //app.UseErrorPage();


            app.Run(async (context) =>
            {
                if (context.Request.Query.ContainsKey("throw"))
                    throw new AggregateException("Some funny exception, 42");

                await context.Response.WriteAsync("Hello World!");
            });            
        }
开发者ID:rafsan,项目名称:Cancel,代码行数:28,代码来源:Startup.cs

示例10: 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

示例11: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
        {
            // Configure the HTTP request pipeline.
            // Add the console logger.
            loggerfactory.AddConsole();

            // Add the following to the request pipeline only in development environment.
            if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase))
            {
                app.UseBrowserLink();
                app.UseErrorPage(ErrorPageOptions.ShowAll);
            }
            else
            {
                // Add Error handling middleware which catches all application specific errors and
                // send the request to the following path or controller action.
                app.UseErrorHandler("/Home/Error");
            }

            // 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" });
            });
        }
开发者ID:LeoLcy,项目名称:MVC6Recipes,代码行数:32,代码来源:Startup.cs

示例12: 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

示例13: Configure

        public void Configure(IApplicationBuilder app)
        {
            var kestrel = app.ServerFeatures[typeof(IKestrelServerInformation)] as IKestrelServerInformation;

            if (kestrel != null)
            {
                // Using an I/O thread for every 2 logical CPUs appears to be a good ratio
                kestrel.ThreadCount = Environment.ProcessorCount >> 1;
                kestrel.NoDelay = true;
            }

            app.UseErrorHandler();
            app.UsePlainText();
            app.UseJson();

            if (StartupOptions.EnableDbTests)
            {
                app.UseSingleQueryRaw(StartupOptions.ConnectionString);
                app.UseSingleQueryEf();
                var dbContext = (ApplicationDbContext)app.ApplicationServices.GetService(typeof(ApplicationDbContext));
                var seeder = (ApplicationDbSeeder)app.ApplicationServices.GetService(typeof(ApplicationDbSeeder));
                if (!seeder.Seed(dbContext))
                {
                    Environment.Exit(1);
                }
                Console.WriteLine("Database tests enabled");
            }

            app.UseMvc();

            app.Run(context => context.Response.WriteAsync("Try /plaintext instead"));
        }
开发者ID:thehousecat,项目名称:benchmarks,代码行数:32,代码来源:Startup.cs

示例14: 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

示例15: Configure

        public void Configure(IApplicationBuilder app)
        {
            var config = new Configuration();
            config.AddEnvironmentVariables();
            config.AddJsonFile("config.json");
            config.AddJsonFile("config.dev.json", true);
            config.AddUserSecrets();

            var password = config.Get("password");

            if (config.Get<bool>("RecreateDatabase"))
            {
                var context = app.ApplicationServices.GetService<Models.BlogDataContext>();
                context.Database.EnsureDeleted();
                System.Threading.Thread.Sleep(2000);
                context.Database.EnsureCreated();
            }


            if (config.Get<bool>("debug"))
            {
                app.UseErrorPage();
                app.UseRuntimeInfoPage();
            }
            else
            {
                app.UseErrorHandler("/home/error");
            }

            app.UseMvc(routes => routes.MapRoute(
                "Default", "{controller=Home}/{action=Index}/{id?}"));

            app.UseFileServer();
        }
开发者ID:lukehammer,项目名称:AspNetBlog,代码行数:34,代码来源:Startup.cs


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