【问题标题】:Asp.net core site hangs after about 50 requests大约 50 个请求后,Asp.net 核心站点挂起
【发布时间】:2018-03-15 03:46:51
【问题描述】:

我使用 asp net core 2.0 并且遇到了非常奇怪的行为(至少我在本地使用 IIS express 看到了它)。我打开网站页面,然后按刷新按钮大约 50 次,网站开始挂起,处理请求大约需要 40 秒。然后在空闲大约 5 分钟后,我再次刷新页面,一切都运行得很快。接下来〜50个请求,它再次挂起。我对此感到非常困惑,并且不知道原因是什么以及如何解决它。我从代码中删除了所有东西,只剩下基本代码,它仍然可以重现。

我的 Startup 类看起来是这样的:

public class Startup
{
    public Startup(IConfiguration configuration)
    {
        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)
    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        services.AddMvc();

        return services.BuildServiceProvider();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IHostingEnvironment env)
    {
        app.Use(async delegate(HttpContext context, Func<Task> next)
        {
            await next.Invoke();
        });

        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
        }

        app.UseStaticFiles();

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

控制器动作不做任何事情,它们只是返回视图。在调试中我经常看到它挂在“await next.Invoke();”上行(我添加此委托仅用于调试)但我不确定问题是否正在执行中。

也许有人知道可能是什么原因或我如何解决它?

【问题讨论】:

  • 只是猜测,但也许您正在达到 IIS express 的某种最大请求?
  • @Jason Roner,感谢您的回复。这很奇怪,但 Visual Studio 和 IIS 更新似乎已经解决了这个问题。

标签: asp.net-core iis-express


【解决方案1】:

看起来问题以意想不到的方式解决了 - 我更新了 Visual Studio,我看到 IIS 也随之更新。

【讨论】:

    猜你喜欢
    • 2018-11-15
    • 2017-04-09
    • 1970-01-01
    • 2022-12-12
    • 2013-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多