大家好,我们团队现在用开发环境是vs2010 .net 2.o framework asp.net, 昨天项目从.net 2.0 升级到。.net 4.0项目以后发现网站运行十分缓慢,页面95%的页面都无打开,即使打开首页也需要好几分钟,经过我们排查只有,发现移除一个附加httpmodel 以后项目就正常运行了,但是我们必须要次httpmodel 功能才正常,否则有部分功能无法使用,通过对应用程序的监控发现在这个httpModel 中有一个事件运行时间超过2~4分钟,请大家帮我分析一下具体产生的原因,请大家不吝指教

------------------------------------------------------------------------------
public class UrlAppendParams : System.Web.IHttpModule
{
private long refId = 0;
private string authCode = string.Empty;

public void Init(HttpApplication application)
{
application.PostMapRequestHandler += new EventHandler(Application_PostMapRequestHandler);
application.AcquireRequestState += new EventHandler(Application_AcquireRequestState);
application.PostAcquireRequestState += new EventHandler(Application_PostAcquireRequestState);
application.PostRequestHandlerExecute += new EventHandler(Application_ApplyUrlFilter);
HttpContext.Current.Trace.Write(MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToLongTimeString());

}
具体出问题的事件方法就是此方法,在asp.net 2.0 的运行环境下正常,在asp.net 4.0 的运行环境运行时时间超过4分钟。

private voidApplication_PostMapRequestHandler
(object source, EventArgs e)
{
HttpContext.Current.Trace.Write(MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToLongTimeString());
HttpApplication application = (HttpApplication)source;

if (application.Context.Handler is IReadOnlySessionState || application.Context.Handler is IRequiresSessionState)
{
// no need to replace the current handler
return;
}

// swap the current handler
application.Context.Handler = newUrlParamsFilterHttpHandler
(application.Context.Handler);

}
。。。。。。。。。。
}
public classUrlParamsFilterHttpHandler
: IHttpHandler, IRequiresSessionState
{
internal readonly IHttpHandler OriginalHandler;

public UrlParamsFilterHttpHandler()
{
OriginalHandler = HttpContext.Current.Handler;
HttpContext.Current.Trace.Write(MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToLongTimeString());
}

public UrlParamsFilterHttpHandler(IHttpHandler originalHandler)
{
OriginalHandler = originalHandler;
HttpContext.Current.Trace.Write(MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToLongTimeString());
}

public void ProcessRequest(HttpContext context)
{
HttpContext.Current.Trace.Write(MethodInfo.GetCurrentMethod().Name, DateTime.Now.ToLongTimeString());
//// do not worry, ProcessRequest() will not be called, but let's be safe
//throw new InvalidOperationException("MyHttpHandler cannot process requests.");
}

public bool IsReusable
{
// IsReusable must be set to false since class has a member!
get { return false; }
}
}
是否是2.0 和4.0 有很大的区别吗?asp.net 生命周期应该是一样的啊,如果这个有问题的话,还有没有其他方法可以替代解决此问题呢。请大家多多指教。