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


C# IApplicationBuilder.UseStatusCodePages方法代码示例

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


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

示例1: Configure

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

            app.UseStatusCodePages();
            app.UseErrorPage();

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    "controllerActionRoute",
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" },
                    constraints: null,
                    dataTokens: new { NameSpace = "default" });

                routes.MapRoute(
                    "controllerRoute",
                    "{controller}",
                    new { controller = "Home" });
            });
        }
开发者ID:andyshao,项目名称:BootstrapMvc,代码行数:25,代码来源:Startup.cs

示例2: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
            ILoggerFactory loggerFactory)
        {
            // The hosting environment can be found in a project's properties -> DEBUG or in launchSettings.json.
            if (_hostingEnvironment.IsDevelopment())
            {
                // The exception page is only shown if the app is in development mode.
                app.UseDeveloperExceptionPage();
            }

            // This middleware makes sure our app is correctly invoked by IIS.
            app.UseIISPlatformHandler();

            // Add the MVC middleware service above first. Then use said middleware in this method.
            //app.UseMvc(routes =>
            //{
            //    routes.MapRoute(
            //        name: "default",
            //        template: "{controller}/{action}/{id}",
            //        defaults: new { controller = "Home", action = "Index" }
            //    );
            //});

            app.UseMvcWithDefaultRoute();

            // Always remember to add the static files middleware or the images from JavaScript or CSS 
            // won't be served.
            app.UseStaticFiles();

            // Whenever HTTP status codes like 404 arise, the below middleware will display them on the page.
            app.UseStatusCodePages();
        }
开发者ID:jimxshaw,项目名称:samples-csharp,代码行数:33,代码来源:Startup.cs

示例3: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole((category, level) =>
            {
                if (category.StartsWith("Microsoft."))
                {
                    return level >= LogLevel.Information;
                }

                return level >= LogLevel.Verbose;
            });

            app.UseStatusCodePages();
            app.UseFileServer();

            app.UseRequestLocalization(new RequestCulture("en-US"));

            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
                routes.MapRoute(
                    "controllerActionRoute",
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" },
                    constraints: null,
                    dataTokens: new { NameSpace = "default" });

                routes.MapRoute(
                    "controllerRoute",
                    "{controller}",
                    new { controller = "Home" });
            });
        }
开发者ID:huoxudong125,项目名称:Mvc,代码行数:34,代码来源:Startup.cs

示例4: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseStaticFiles();
            app.UseStatusCodePages();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new {controller = "Home", action = "Index"});
            });

            app.UseOwin(addToPipeline =>
            {
                addToPipeline(next =>
                {
                    var builder = new AppBuilder();
                    var hubConfig = new HubConfiguration { EnableDetailedErrors = true };

                    builder.MapSignalR(hubConfig);

                    var appFunc = builder.Build(typeof(Func<IDictionary<string, object>, Task>)) as Func<IDictionary<string, object>, Task>;

                    return appFunc;
                });
            });
        }
开发者ID:swanitzek,项目名称:ASP5-MVC6-SignalR2,代码行数:28,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseStatusCodePages();
            app.UseFileServer();

            if (_autoFac)
            {
                app.UseMiddleware<MonitoringMiddlware>();
            }
            app.UseRequestLocalization();

            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
                routes.MapRoute(
                    "controllerActionRoute",
                    "{controller}/{action}",
                    new { controller = "Home", action = "Index" },
                    constraints: null,
                    dataTokens: new { NameSpace = "default" });

                routes.MapRoute(
                    "controllerRoute",
                    "{controller}",
                    new { controller = "Home" });
            });
        }
开发者ID:ryanbrandenburg,项目名称:Mvc,代码行数:28,代码来源:Startup.cs

示例6: Configure

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

            app.UseMvc();
        }
开发者ID:aggieben,项目名称:fex,代码行数:8,代码来源:Startup.cs

示例7: Configure

	public void Configure(IApplicationBuilder app)
	{
		app
			.UseStatusCodePages()
			.UseFileServer()
			.UseMvcWithDefaultRoute()
		;
	}
开发者ID:erlimar,项目名称:blog.erlimar.com,代码行数:8,代码来源:Startup.cs

示例8: Configure

        public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment hostingEnvironment)
        {
            applicationBuilder.UseSession();

              if (hostingEnvironment.IsEnvironment("Development"))
              {
            applicationBuilder.UseStatusCodePages();
            applicationBuilder.UseErrorPage();
            applicationBuilder.UseBrowserLink();
              }

              else
              {
            applicationBuilder.UseStatusCodePages();
            applicationBuilder.UseErrorHandler("/Default/Error");
              }

              applicationBuilder.UseStaticFiles();
              applicationBuilder.UseCookieAuthentication(options => {
            options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            options.AutomaticAuthentication = true;
            options.CookieName = "PLATFORMUS";
            options.ExpireTimeSpan = new System.TimeSpan(1, 0, 0);
            options.LoginPath = new PathString("/Backend/Account/SignIn");
              });

              RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions();

              requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider());
              applicationBuilder.UseRequestLocalization(requestLocalizationOptions);

              applicationBuilder.UseMvc(routes =>
            {
              // Backend
              routes.MapRoute(name: "Backend Create", template: "{area:exists}/{controller=Default}/create", defaults: new { action = "CreateOrEdit" });
              routes.MapRoute(name: "Backend Edit", template: "{area:exists}/{controller=Default}/edit/{id}", defaults: new { action = "CreateOrEdit" });
              routes.MapRoute(name: "Backend Default", template: "{area:exists}/{controller=Default}/{action=Index}/{id?}");

              // Frontend
              //routes.MapRoute(name: "Standard", template: "{controller=Default}/{action=Index}/{id?}", defaults: new { }, constraints: new { controller = " " });
              routes.MapRoute(name: "Default", template: "{culture=en}/{*url}", defaults: new { controller = "Default", action = "Index" });
            }
              );
        }
开发者ID:OlegDokuka,项目名称:Platformus,代码行数:44,代码来源:Startup.cs

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

            app.UseApplicationInsightsRequestTelemetry();
            
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseStatusCodePages();
                using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope())
                {
                    using (var dbContext = serviceScope.ServiceProvider.GetService<ApplicationDbContext>())
                    {
                        dbContext.Database.Migrate();
                        DatabaseInitialization.Initialize(dbContext);
                    }
                }
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                        .CreateScope())
                    {
                        using (var dbContext = serviceScope.ServiceProvider.GetService<ApplicationDbContext>())
                        {
                            dbContext.Database.Migrate();
                            DatabaseInitialization.Initialize(dbContext);
                        }
                    }
                }
                catch
                {
                }
            }

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

            // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715

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

示例10: Configure

        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseStatusCodePages(subApp =>
                {
                    subApp.Run(async context =>
                    {
                        context.Response.ContentType = "text/html";
                        await context.Response.WriteAsync($"Error @ {context.Response.StatusCode}");
                    });
                });
            }

            logFactory.AddConsole(LogLevel.Trace);
            logFactory.AddSerilog();

            var logger = logFactory.CreateLogger<Startup>();

            logger.LogTrace("Trace msg");
            logger.LogDebug("Debug msg");
            logger.LogInformation("Info msg");
            logger.LogWarning("Warn msg");
            logger.LogError("Error msg");
            logger.LogCritical("Critical msg");

            app.UseMiddleware<RequestIdMiddleware>();

            //app.Run(ctx =>
            //{
            //    //throw new Exception("some error");
            //    //ctx.Response.StatusCode = 500;
            //    return Task.FromResult(0);
            //});


            //app.UseIISPlatformHandler();
            //app.UseFileServer();
            var router = new RouteBuilder(app)
                .MapGet("", async ctx => await ctx.Response.WriteAsync("Hello from routing"))
                .MapGet("sub", async ctx => await ctx.Response.WriteAsync("Hello from sub"))
                .MapGet("item/{id:int}", ctx => ctx.Response.WriteAsync($"Item ID: {ctx.GetRouteValue("id")}"))
                ;
            
            app.UseRouter(router.Build());
            app.UseMvc();

       
            //app.UseRequestCulture();
            //app.Run(async ctx => await ctx.Response.WriteAsync($"Hello {CultureInfo.CurrentCulture.DisplayName}"));
            //app.Run(async ctx => await ctx.Response.WriteAsync($"{Configuration["greeting"]}"));
        }
开发者ID:eaardal,项目名称:aspnet5-workshop,代码行数:56,代码来源: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, ILoggerFactory loggerFactory)
        {
            if (Environment.IsDevelopment())
                app.UseDeveloperExceptionPage();

            app.UseIISPlatformHandler();

            app.UseMvcWithDefaultRoute();
            app.UseStaticFiles();
            app.UseStatusCodePages();
        }
开发者ID:johnnyoshika,项目名称:fishtankapp,代码行数:12,代码来源:Startup.cs

示例12: Configure

        public void Configure(IApplicationBuilder app, IOptions<AppSettings> settings)
        {
            // Insert a new cookies middleware in the pipeline to store the user
            // identity after he has been redirected from the identity provider.
            app.UseCookieAuthentication(options =>
            {
                options.AutomaticAuthentication = true;
                options.AuthenticationScheme = "Cookies";
                options.CookieName = "Cookies";
                // options.CookieDomain = ".localhost.me";
                options.ExpireTimeSpan = TimeSpan.FromMinutes(5);
                options.LoginPath = new PathString("/login");

            });
            app.UseClaimsTransformation(options =>
            {
                // options.Transformer.Transform();
            });

            // Add static files
            app.UseStaticFiles();
            app.UseStatusCodePages();
            // Choose an authentication type
            app.Map("/login", signoutApp =>
            {
                signoutApp.Run(async context =>
                {
                    await
                        context.Authentication.ChallengeAsync("Cookies");
                    return;
                });
            });

            // Sign-out to remove the user cookie.
            app.Map("/logout", signoutApp =>
            {
                signoutApp.Run(async context =>
                {
                    await context.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);

                });
            });

            // Add MVC
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new {controller = "Home", action = "Index"}
                    );
            });
        }
开发者ID:mikeandersun,项目名称:experimental,代码行数:53,代码来源: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();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            //app.UseBrickPile();

            //app.UseMvc(routes =>
            //{
            //    //routes.DefaultHandler = new DefaultRouter(routes.DefaultHandler);
            //});

            //app.UseIISPlatformHandler();

            app.UseStatusCodePages();

            app.UseStaticFiles();

            // Add localization to the request pipeline.
            app.UseBrickPile(options =>
            {
                options.DefaultRequestCulture = new RequestCulture("en");
                options.SupportedCultures = new List<CultureInfo>
                {
                    new CultureInfo("en"),
                    new CultureInfo("sv")
                };
                options.SupportedUICultures = new List<CultureInfo>
                {
                    new CultureInfo("en"),
                    new CultureInfo("sv")
                };
            });

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

示例14: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app)
        {
            if (hostingEnvironment.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseIISPlatformHandler();
            app.UseMvcWithDefaultRoute();
          
            app.UseStaticFiles();
            app.UseStatusCodePages();

        }
开发者ID:juanjardim,项目名称:fishTank,代码行数:14,代码来源:Startup.cs

示例15: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, DataContext dataContext, IDatabase redisDb)
        {
            loggerFactory.AddConsole();

            ensureDatabase(dataContext);
            ensureRedis(redisDb);

            app.UseStatusCodePages();
            app.UseDeveloperExceptionPage();

            app.UseCors(policyBuilder => policyBuilder.AllowAnyOrigin().AllowAnyMethod());
            app.UseMvc();
        }
开发者ID:colemickens,项目名称:dotkube_____old,代码行数:13,代码来源:Startup.cs


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