为什么Firefox,IE11和野生动物园在“接收”中花费2分钟进行重定向(302)?

时间:2019-02-19 15:34:53

标签: asp.net-core firewall

我有一个应用程序,它将作为子应用程序托管在IIS上。附有Startup.cs。该应用程序在Chrome和Edge中正常运行。在FireFox,IE11和Safari / iPhone中,重定向到另一个页面需要2分钟。开发人员工具中的计时表明,几乎所有时间都花在“接收”上。

我了解到chrome在缓存方面存在问题,但对我来说效果很好。

我尝试过的事情:
-删除了AddAutheentication
添加的缓存控件(当前已注释)

有什么想法吗?

更新,其他信息:问题站点位于FortiWeb防火墙后面。 更新2:当安装在不位于防火墙后面的服务器上时,该站点在所有浏览器中的运行情况都很好。因此系统专家正在研究Fortiweb。关于可能的问题有什么想法?在FoertiWeb之后,我们不是唯一在IIS上运行Core 2.2站点的人。

namespace OVNew
{
    public class Startup
    {
        public Startup(IHostingEnvironment env)
        {
            //to add support for different environments, watch:
            //https://www.youtube.com/watch?v=nIoDpTPIle8

            var Builder = new ConfigurationBuilder()
                .SetBasePath(env.ContentRootPath)
                .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
                .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                .AddEnvironmentVariables();//for secret keys etc
            Configuration = Builder.Build();

            string subPath = Environment.GetEnvironmentVariable("SUB_PATH");
            //Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            //https://www.youtube.com/watch?v=nIoDpTPIle8
            services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));

            services.AddMvc()
                    .AddRazorPagesOptions(options =>
                    {
                        options.Conventions.AuthorizePage("/Survey/Index");
                        options.Conventions.AuthorizeFolder("/Survey");
                    })
                    .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            //use Cookie.Path to limit cookie to specific application
            services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
                .AddCookie(options =>
                {
                    options.Cookie.SameSite = SameSiteMode.Strict;
                    options.AccessDeniedPath = "/AccessDenied";
                });

            services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();

            var connection = Configuration.GetConnectionString("OVContext");
            services.AddDbContext<OVContext>(options => options.UseSqlServer(connection));
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

    //           app.Use(async (c, next) =>
    //           {
    //               c.Response.Headers.Add("Cache-Control", "no-store,no-cache");
    //               c.Response.Headers.Add("Pragma", "no-cache");
    //               await next();
    //           });

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

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

0 个答案:

没有答案