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


C# IApplicationBuilder.UseErrorPage方法代码示例

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


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

示例1: Configure

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

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseErrorPage();
            }
            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:adrien-f,项目名称:SuperDeploy,代码行数:34,代码来源: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();
            loggerFactory.AddDebug();

            // Configure the HTTP request pipeline.

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

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

            // Add MVC to the request pipeline.
            app.UseMvc();
        }
开发者ID:nteague22,项目名称:Lighthouse.Site,代码行数:28,代码来源:Startup.cs

示例3: Configure

    public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
    {
        loggerFactory.AddConsole();
		app.UseErrorPage();
		app.UseStaticFiles();
		app.UseMvcWithDefaultRoute();        
    }
开发者ID:kheerthiimandi,项目名称:asp.net5-cloudant,代码行数:7,代码来源:Startup.cs

示例4: Configure

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

            //if (env.IsDevelopment())
            //{
                app.UseErrorPage();
            //}
            //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.UseIISPlatformHandler();
            app.UseStaticFiles();

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

示例5: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Add static files to the request pipeline
            app.UseStaticFiles();

            // Add cookie-based authentication to the request pipeline
            app.UseIdentity();

            // Add the following to the request pipeline only in development environment.
            if (env.IsEnvironment("Development"))
            {
                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);

            app.ConfigureSecurity();

            //Configure SignalR
            app.UseSignalR();

            // Add MVC to the request pipeline
            app.ConfigureRoutes();

            MyShuttleDataInitializer.InitializeDatabaseAsync(app.ApplicationServices).Wait();

        }
开发者ID:EmiiFont,项目名称:MyShuttle_RC,代码行数:29,代码来源:Startup.cs

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

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

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

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

示例10: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseErrorPage();

            app.Run(async (context) =>
            {
                IFormFile fullImgFile = null;
                if (context.Request.HasFormContentType)
                {
                    fullImgFile = context.Request?.Form?.Files?.GetFile("fieldNameHere");
                }
                if (fullImgFile != null)
                {
                    using (MemoryStream memoryStream = new MemoryStream())
                    {
                        using (var fullImgStream = fullImgFile.OpenReadStream())
                        {
                            await fullImgStream.CopyToAsync(memoryStream);
                        }

                        var fullImgBytes = memoryStream.ToArray();
                        var thumbnailBytes = PngThumbnailer.CreateThumbnail(fullImgBytes);

                        context.Response.Headers["Content-Type"] = "img/png";
                        context.Response.Headers["Content-Length"] = thumbnailBytes.Length.ToString();

                        await context.Response.Body.WriteAsync(thumbnailBytes, 0, thumbnailBytes.Length);
                    }
                }
                else
                {
                    await context.Response.WriteAsync("Hello World!");
                }
            });
        }
开发者ID:halter73,项目名称:seattlecodecamp,代码行数:35,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory LoggerFactory, ILogger<Startup> logger)
        {
            LoggerFactory.AddConsole(LogLevel.Information);

            app.Use(async (context, next) =>
            {
                var s = ("[Pipeline] Request to:" + context.Request.Path);
                logger.LogInformation(s);
                Debug.WriteLine(s);
                await next();
            });

            //app.Use(async (context, next) =>
            //{
            //	var s = ("Headers:\n" + JsonConvert.SerializeObject(context.Request.Headers, Formatting.Indented));
            //	logger.LogInformation(s);
            //	Debug.WriteLine(s);

            //	s = ("Body:\n" + JsonConvert.SerializeObject(context.Request.Form, Formatting.Indented));
            //	logger.LogInformation(s);
            //	Debug.WriteLine(s);

            //	await next();
            //});

            app.UseStaticFiles();
            app.UseErrorPage();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Page", action = "Index" });
            });
        }
开发者ID:kfwls,项目名称:starters,代码行数:35,代码来源:Startup.cs

示例12: Configure

        // Configure is called after ConfigureServices is called.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole((name, logLevel) =>
              name.StartsWith("Microsoft.AspNet.Mvc.TagHelpers", StringComparison.OrdinalIgnoreCase)
              || (name.StartsWith("Microsoft.Net.Http.Server.WebListener", StringComparison.OrdinalIgnoreCase)
                  && logLevel >= LogLevel.Information));

            // Configure the HTTP request pipeline.

            // Add the following to the request pipeline only in development environment.
            if (env.IsDevelopment())
            {
                app.UseErrorPage();
            }
            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:peterblazejewicz,项目名称:CustomTagHelper,代码行数:36,代码来源:Startup.cs

示例13: Configure

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

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

            app.UseStaticFiles();
            app.UseIdentity();
            app.UseSession();

            // 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=Home}/{action=Index}/{id?}");
            });
        }
开发者ID:writeline,项目名称:Lockr,代码行数:35,代码来源:Startup.cs

示例14: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseErrorPage();

            app.UseMvcWithDefaultRoute();
            app.UseWelcomePage();
        }
开发者ID:m3smgii2002,项目名称:networkplanner,代码行数:7,代码来源:Startup.cs

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


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