Update of /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv25322
Modified Files:
PageHandlerFactory.cs
Log Message:
temporary fix for SPRNET-899
Index: PageHandlerFactory.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/src/Spring/Spring.Web/Web/Support/PageHandlerFactory.cs,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** PageHandlerFactory.cs 4 Apr 2008 20:45:06 -0000 1.38
--- PageHandlerFactory.cs 5 Apr 2008 14:52:44 -0000 1.39
***************
*** 24,27 ****
--- 24,28 ----
using System.Collections;
using System.Collections.Specialized;
+ using System.Reflection;
using System.Security.Permissions;
using System.Web;
***************
*** 168,171 ****
--- 169,177 ----
internal class PageHandlerWrapper : Page, IHttpHandler
{
+ #if NET_2_0
+ private static readonly FieldInfo fiHttpContext_CurrentHandler =
+ typeof (HttpContext).GetField("_currentHandler", BindingFlags.NonPublic | BindingFlags.Instance);
+ #endif
+
private readonly IApplicationContext appContext;
private readonly string pageId;
***************
*** 252,259 ****
}
ApplySharedState(handler);
ApplyDependencyInjection(handler);
- context.Handler = handler;
handler.ProcessRequest(context);
}
--- 258,280 ----
}
+ // replace handler proxy on context with "real" handler
+ if (this == context.Handler)
+ {
+ context.Handler = handler;
+ }
+
+ #if NET_2_0
+ // this may happen under load, if GetHandler()
+ // and ProcessRequest() are executed under different threads
+ // fix this...
+ if (this == context.CurrentHandler)
+ {
+ fiHttpContext_CurrentHandler.SetValue(context, handler);
+ }
+ #endif
+
ApplySharedState(handler);
ApplyDependencyInjection(handler);
handler.ProcessRequest(context);
}
|