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


C# IApplicationBuilder.UseStatusCodePagesWithRedirects方法代码示例

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


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

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

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Hello World!");
            });
            */

            var fileServerOptions = new FileServerOptions
            {
                EnableDefaultFiles = true,
                EnableDirectoryBrowsing = false
            };
            //FileExtensionContentTypeProvider contentTypeProvider = (FileExtensionContentTypeProvider)fileServerOptions.StaticFileOptions.ContentTypeProvider;
            //contentTypeProvider.Mappings.Remove(".svg");
            //contentTypeProvider.Mappings.Add(".svg", "image/svg+xml");
            app.UseFileServer(fileServerOptions);

            //app.UseErrorPage();

            // ToDo: Only route to this from /index.php/calendar/
            app.UseStatusCodePagesWithRedirects("/#/WhenWhereModal");
        }
开发者ID:GeekyMonkey,项目名称:CoderDojoEnnisWebsite,代码行数:32,代码来源:Startup.cs

示例2: ConfigurePrototype

        public void ConfigurePrototype(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseWelcomePage("/welcome");
            
            app.UseDeveloperExceptionPage();
            
            app.UseDirectoryBrowser(new DirectoryBrowserOptions()
            {
                FileProvider = new PhysicalFileProvider(@"E:\GitHub\Fan.Chinese.MVC\src\Fan.Chinese.MVC\Properties"),
                RequestPath = new PathString("/Properties")
            });

            app.UseStaticFiles();

            app.UseStatusCodePagesWithRedirects("/NotFoundPage.html");

            app.Run(async (context) =>
            {
                if (context.Request.Query.ContainsKey("throw")) throw new Exception("Exception triggered!");
                context.Response.ContentType = "text/html";
                await context.Response.WriteAsync($"<html><body><h2>Nihao {env.EnvironmentName}!</h2>");
                await context.Response.WriteAsync("<ul>");
                await context.Response.WriteAsync("<li><a href=\"/welcome\">Welcome Page</a></li>");
                await context.Response.WriteAsync("<li><a href=\"/Properties\">Browse Property Directory</a></li>");
                await context.Response.WriteAsync("<li><a href=\"/?throw=true\">Throw Exception</a></li>");
                await context.Response.WriteAsync("</ul>");
                await context.Response.WriteAsync("</body></html>");
            });

        }
开发者ID:misssoft,项目名称:Fan.Chinese.MVC,代码行数:30,代码来源:Startup.cs

示例3: Configure

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            // Use different settings depending on debug or production builds
            if (env.IsDevelopment())
            {
                // Register the Microsoft default Error Handler
                app.UseDeveloperExceptionPage();

                // Register the ASP.NET Runtime Info Page
                app.UseRuntimeInfoPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            
            // Shows an error page when there is a 400 - 599 error
            app.UseStatusCodePagesWithRedirects("/Home/Error");

            // Register MVC Middleware AND specify the routing format
            app.UseMvc(routes => routes.MapRoute("Default", "{controller=Home}/{action=Index}/{id?}"));

            // Register the File Server Middleware
            app.UseFileServer();
        }
开发者ID:Pycorax,项目名称:SP4Unity,代码行数:26,代码来源:Startup.cs

示例4: 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();
            }
            else
            {
                app.UseExceptionHandler("/error");
                app.UseStatusCodePagesWithRedirects("/error/{0}");

                // 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())
                    {
                        serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
                             .Database.Migrate();
                    }
                }
                catch { }
            }

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseStaticFiles();

            app.UseIdentity();

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

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "ErrorPage",
                    template: "error/{action=index}/{errorCode:int}",
                    defaults: new { controller = "error" });
                routes.MapRoute(
                    name: "ArticlesNavigation",
                    template: "{controller=home}/{action=index}/{page:int?}");
                routes.MapRoute(
                    name: "IndexPagination",
                    template: "{page:int}",
                    defaults: new { controller = "home", action = "index" });
                routes.MapRoute(
                    name: "default",
                    template: "{controller=home}/{action=index}/{id?}");
            });
        }
开发者ID:mrtryhard,项目名称:mytryhard,代码行数:58,代码来源:Startup.cs

示例5: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Warning);

            app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");

            // Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the
            // request pipeline.
            // Note: Not recommended for production.
            app.UseDeveloperExceptionPage();
            app.UseDatabaseErrorPage();

            app.Use(async (context, next) =>
            {
                // Who will get admin access? For demo sake I'm listing the currently logged on user as the application
                // administrator. But this can be changed to suit the needs.
                var identity = (ClaimsIdentity)context.User.Identity;

                if (context.User.Identity.Name == Environment.GetEnvironmentVariable("USERDOMAIN") + "\\"
                    + Environment.GetEnvironmentVariable("USERNAME"))
                {
                    identity.AddClaim(new Claim("ManageStore", "Allowed"));
                }

                await next.Invoke();
            });

            // Configure Session.
            app.UseSession();

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

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}",
                    defaults: new { action = "Index" });

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

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            //Populates the MusicStore sample data
            SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices, false).Wait();
        }
开发者ID:Cream2015,项目名称:MusicStore,代码行数:54,代码来源:StartupNtlmAuthentication.cs

示例6: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseStaticFiles();
            app.UseStatusCodePagesWithRedirects("~/error/error{0}");
            //  app.UseDeveloperExceptionPage();

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

示例7: Configure

 public void Configure(IApplicationBuilder app)
 {
     app.UseStaticFiles();
     app.UseStatusCodePagesWithRedirects("~/error/error{0}");
     app.UseApplicationInsightsRequestTelemetry();
     app.UseApplicationInsightsExceptionTelemetry();
     app.UseMvc(routes =>
     {
                 routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}");
     });
 }
开发者ID:ealsur,项目名称:mvpstream,代码行数:11,代码来源:Startup.cs

示例8: ConfigureProduction

        //This method is invoked when ASPNET_ENV is 'Production'
        //The allowed values are Development,Staging and Production
        public void ConfigureProduction(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Warning);

            // StatusCode pages to gracefully handle status codes 400-599.
            app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");

            app.UseExceptionHandler("/Home/Error");

            Configure(app);
        }
开发者ID:JensKlambauer,项目名称:MVC6_Testprojects,代码行数:13,代码来源:Startup.cs

示例9: Configure

        //public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        //{
        //    app.Map("/SpotifyChangeControl", map => Configure1(map, env, loggerFactory));
        //}
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            //Setup Routes

            //Setup Auth
            //BEGIN RJB 9/10/2016
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage(); //ADDED THIS TO HAVE EXCEPTION PAGES INT MY APP WHEN IT IS IN DEBUG MODE ONLY
            }
            else //WHEN NOT IN DEBUG THEN HAVE SOMETHING COOLER
            {
                app.UseExceptionHandler("/Errors");
               app.UseStatusCodePagesWithRedirects("~/Errors/GetCustomErrorPageToMakeTheStupidHumanFeelGoodAboutThereTecnicalAbilitiesAndReassureThemItsNotTheirFault?sHttpStatus={0}");
               //app.UseStatusCodePagesWithReExecute("/Errors/GetCustomErrorPageToMakeTheStupidHumanFeelGoodAboutThereTecnicalAbilitiesAndReassureThemItsNotTheirFault?sHttpStatus={0}");
            }
            //END RJB 9/10/2016

            app.UseStaticFiles();

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AutomaticAuthenticate = true,
                AutomaticChallenge = true,
                AccessDeniedPath = new PathString("/Account/Forbidden/"),
                LoginPath = new PathString("/Account/Login/"),
                LogoutPath = new PathString("/Account/Logout/")
            });

            SpotifyChangeControlLib.SCCManager oSCCManager = new SpotifyChangeControlLib.SCCManager();
            var Options = new AspNet.Security.OAuth.Spotify.SpotifyAuthenticationOptions()
            {
                ClientId = oSCCManager.SCC_PUBLIC_ID,
                ClientSecret = oSCCManager.SCC_PRIVATE_ID,

            };

            Options.Scope.Add("playlist-read-private");
            Options.Scope.Add("user-read-private");
            Options.Scope.Add("user-read-email");
            Options.Scope.Add("user-library-read");
            Options.Scope.Add("user-follow-read");
            app.UseSpotifyAuthentication(Options);

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

示例10: ConfigureDevelopment

        // This method is invoked when ASPNET_ENV is 'Development' or is not defined
        // The allowed values are Development,Staging and Production
        public void ConfigureDevelopment(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Warning);

            // StatusCode pages to gracefully handle status codes 400-599.
            app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");

            // Display custom error page in production when error occurs
            // During development use the ErrorPage middleware to display error information in the browser
            app.UseDeveloperExceptionPage();

            app.UseDatabaseErrorPage();

            // Add the runtime information page that can be used by developers
            // to see what packages are used by the application
            // default path is: /runtimeinfo
            app.UseRuntimeInfoPage();

            Configure(app);
        }
开发者ID:JensKlambauer,项目名称:MVC6_Testprojects,代码行数:22,代码来源:Startup.cs

示例11: Configure

        public void Configure(IApplicationBuilder app)
        {
            app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new[] { "index.html" } });
            app.UseStaticFiles();

            app.UseDeveloperExceptionPage();
            app.UseStatusCodePagesWithRedirects("/");

            app.UseApplicationInsightsRequestTelemetry();
            app.UseApplicationInsightsExceptionTelemetry();

            app.UseMvc(routes =>
            {
                routes.MapRoute("default", "{controller}/{action}/{id?}",
                    new { controller = "Home", action = "Index", id = 0 });
                routes.MapRoute("page", "{url}",
                    new { controller = "Home", action = "Page" });
                routes.MapRoute("sub-page", "{category}/{url}",
                    new { controller = "Home", action = "SubPage" });
            });
        }
开发者ID:stevedesmond-ca,项目名称:SteveDesmond.ca,代码行数:21,代码来源:Startup.cs

示例12: 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.UseBrowserLink();
              }
              else
              {
            app.UseExceptionHandler("/Error/Internal");
              }

              app.UseStatusCodePagesWithRedirects("/Error/PageNotFound");

              app.UseStaticFiles();

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

            routes.MapRoute(
              name: "default_simple",
              template: "{action}",
              defaults: new { controller = "Home" });

            routes.MapRoute(
              name: "portfolio_full",
              template: "{controller}/{action}",
              defaults: new { controller = "Portfolio", action = "Index" });
              });
        }
开发者ID:olegburov,项目名称:AnnetKatan-Photography,代码行数:38,代码来源:Startup.cs

示例13: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Warning);

            app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");

            // Display custom error page in production when error occurs
            // During development use the ErrorPage middleware to display error information in the browser
            app.UseDeveloperExceptionPage();

            app.UseDatabaseErrorPage();

            // Add the runtime information page that can be used by developers
            // to see what packages are used by the application
            // default path is: /runtimeinfo
            app.UseRuntimeInfoPage();

            // Configure Session.
            app.UseSession();

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

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

            // Create an Azure Active directory application and copy paste the following
            app.UseOpenIdConnectAuthentication(options =>
            {
                options.Authority = "https://login.windows.net/[tenantName].onmicrosoft.com";
                options.ClientId = "c99497aa-3ee2-4707-b8a8-c33f51323fef";
                options.BackchannelHttpHandler = new OpenIdConnectBackChannelHttpHandler();
                options.StringDataFormat = new CustomStringDataFormat();
                options.StateDataFormat = new CustomStateDataFormat();
                options.TokenValidationParameters.ValidateLifetime = false;
                options.ProtocolValidator.RequireNonce = true;
                options.ProtocolValidator.NonceLifetime = TimeSpan.FromDays(36500);
                options.UseTokenLifetime = false;

                options.Events = new OpenIdConnectEvents
                {
                    OnMessageReceived = TestOpenIdConnectEvents.MessageReceived,
                    OnAuthorizationCodeReceived = TestOpenIdConnectEvents.AuthorizationCodeReceived,
                    OnRedirectToAuthenticationEndpoint = TestOpenIdConnectEvents.RedirectToAuthenticationEndpoint,
                    OnAuthenticationValidated = TestOpenIdConnectEvents.AuthenticationValidated,
                    OnAuthorizationResponseReceived = TestOpenIdConnectEvents.AuthorizationResponseRecieved
                };
            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}",
                    defaults: new { action = "Index" });

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

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            //Populates the MusicStore sample data
            SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
        }
开发者ID:leloulight,项目名称:MusicStore,代码行数:70,代码来源:StartupOpenIdConnectTesting.cs

示例14: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Warning);

            app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");

            // Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
            // Note: Not recommended for production.
            app.UseErrorPage();

            app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);

            // Add the runtime information page that can be used by developers
            // to see what packages are used by the application
            // default path is: /runtimeinfo
            app.UseRuntimeInfoPage();

            // Configure Session.
            app.UseSession();

            //Configure SignalR
            app.UseSignalR();

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

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

            app.UseFacebookAuthentication();

            app.UseGoogleAuthentication();

            app.UseTwitterAuthentication();

            app.UseMicrosoftAccountAuthentication();

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}",
                    defaults: new { action = "Index" });

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

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            //Populates the MusicStore sample data
            SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
        }
开发者ID:Glimpse,项目名称:MusicStore,代码行数:58,代码来源:StartupSocialTesting.cs

示例15: Configure

        public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(minLevel: LogLevel.Warning);

            app.UseStatusCodePagesWithRedirects("~/Home/StatusCodePage");

            // Display custom error page in production when error occurs
            // During development use the ErrorPage middleware to display error information in the browser
            app.UseDeveloperExceptionPage();

            app.UseDatabaseErrorPage();

            // Add the runtime information page that can be used by developers
            // to see what packages are used by the application
            // default path is: /runtimeinfo
            app.UseRuntimeInfoPage();

            // Configure Session.
            app.UseSession();

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

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

            // Create an Azure Active directory application and copy paste the following
            app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
            {
                Authority = "https://login.windows.net/[tenantName].onmicrosoft.com",
                ClientId = "[ClientId]",
                ResponseType = OpenIdConnectResponseTypes.CodeIdToken,
            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areaRoute",
                    template: "{area:exists}/{controller}/{action}",
                    defaults: new { action = "Index" });

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

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });

            //Populates the MusicStore sample data
            SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
        }
开发者ID:Corays,项目名称:MusicStore,代码行数:55,代码来源:StartupOpenIdConnect.cs


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