视图和控制器以及Ajax调用之间的等待时间很长



问题是项目到达控制器所需的时间大约需要一分钟。示例:我转到"中的索引;mycontroller";,并且索引开始处的断点需要一分钟或更长时间才能被激活。

然后,整个过程需要几秒钟的时间来发送视图,但任何重新加载都需要很长时间,对用户来说都不是一个可行的等待时间。视图中的任何Ajax调用都需要很长时间才能到达我正在调用的函数。

这是昨天(12月13日-21日(开始的,我不知道是什么原因造成了延误。如果我不够清楚,我会在控制器函数(ActionResult(的开头放一个断点。活跃起来大约需要一分钟或更长时间。然后我点击continue,几秒钟后视图就被加载了。问题是视图和控制器之间突然出现了长达一分钟的等待。任何Ajax调用都会发生同样的情况。

感谢您的帮助。这是我激活的唯一过滤器。在我给[AllowAnonyment]打了几个电话后,反应似乎有所改善

public class AuthorizationFilter : AuthorizeAttribute, IAuthorizationFilter
{
public override void OnAuthorization(AuthorizationContext filterContext)
{
if (filterContext.ActionDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true)
|| filterContext.ActionDescriptor.ControllerDescriptor.IsDefined(typeof(AllowAnonymousAttribute), true))
{
// Don't check for authorization as AllowAnonymous filter is applied to the action or controller  
return;
}
// Check for authorization  
if (HttpContext.Current.Session["key"] == null || HttpContext.Current.Session["user"] == null)
{
filterContext.Result = new RedirectResult("~/Login/");
}
}
}

您应该检查:

  • 过滤器:AuthenticationFilterAuthorizeFilterActionFilter。。。并且在执行操作之前运行任何过滤器
  • 用于长负载的depedements contractor/controller contractor

你可以在这里查看Asp.net的管道。

最新更新