コード例 #1
0
ファイル: Startup.cs プロジェクト: Sitecore/MVP-Site
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            // When running behind HTTPS termination, set the request scheme according to forwarded protocol headers.
            // Also set the Request IP, so that it can be passed on to the Sitecore Layout Service for tracking and personalization.
            app.UseForwardedHeaders(ConfigureForwarding(env));
            app.UseSession();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();

                //Add HTTPS redirection, but ignore for healthz path to allow for liveness probes over http
                app.UseWhen(context => !context.Request.Path.StartsWithSegments("/healthz"),
                            builder => builder.UseHttpsRedirection());
            }

            //Add recirects for old mvp pages
            var options = new RewriteOptions()
                          .AddRedirect("mvps/(.*)", "Directory?fc_personyear=$1")
                          .AddRedirect("mvps$", "Directory")
                          .AddRedirect("Search(.*)", "Directory$1");

            app.UseRewriter(options);
            // The Experience Editor endpoint should not be enabled in production DMZ.
            // See the SDK documentation for details.
            if (Configuration.EnableExperienceEditor)
            {
                // Enable the Sitecore Experience Editor POST endpoint.
                app.UseSitecoreExperienceEditor();
            }

            // Standard ASP.NET Core routing and static file support.
            app.UseRouting();
            app.UseStaticFiles();

            // Enable ASP.NET Core Localization, which is required for Sitecore content localization.
            app.UseRequestLocalization(options =>
            {
                // If you add languages in Sitecore which this site / Rendering Host should support, add them here.
                var supportedCultures = new List <CultureInfo> {
                    new CultureInfo(_defaultLanguage)
                };
                options.DefaultRequestCulture = new RequestCulture(_defaultLanguage, _defaultLanguage);
                options.SupportedCultures     = supportedCultures;
                options.SupportedUICultures   = supportedCultures;

                // Allow culture to be resolved via standard Sitecore URL prefix and query string (sc_lang).
                options.UseSitecoreRequestLocalization();
            });

            // Configure Okta Integration
            app.UseFoundationUser();

            app.UseFeatureForms();

            // app.UseCookiePolicy();

            // Enable proxying of Sitecore robot detection scripts
            //app.UseSitecoreVisitorIdentification();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    "error",
                    "error",
                    new { controller = "Default", action = "Error" }
                    );

                endpoints.MapControllerRoute(
                    "healthz",
                    "healthz",
                    new { controller = "Default", action = "Healthz" }
                    );

                endpoints.MapControllerRoute(
                    "getUserEmailClaim",
                    "getUserEmailClaim",
                    new { controller = "Application", action = "GetUserEmailClaim" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep1",
                    "submitStep1",
                    new { controller = "Application", action = "Welcome" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep2",
                    "submitStep2",
                    new { controller = "Application", action = "Category" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep3",
                    "submitStep3",
                    new { controller = "Application", action = "PersonalInformation" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep4",
                    "submitStep4",
                    new { controller = "Application", action = "ObjectivesandMotivation" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep5",
                    "submitStep5",
                    new { controller = "Application", action = "Socials" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep6",
                    "submitStep6",
                    new { controller = "Application", action = "NotableCurrentYearContributions" }
                    );

                endpoints.MapControllerRoute(
                    "submitStep7",
                    "submitStep7",
                    new { controller = "Application", action = "Confirmation" }
                    );

                endpoints.MapControllerRoute(
                    "getCategories",
                    "getCategories",
                    new { controller = "Application", action = "GetCategories" }
                    );


                // Enables the default Sitecore URL pattern with a language prefix.
                endpoints.MapSitecoreLocalizedRoute("sitecore", "Index", "Default");

                // Fall back to language-less routing as well, and use the default culture (en).
                endpoints.MapFallbackToController("Index", "Default");
            });
        }