2007-04-04 Juraj Skripsky <js@hotfeet.ch>
authorJuraj Skripsky <js@hotfeet.ch>
Wed, 4 Apr 2007 13:54:51 +0000 (13:54 -0000)
committerJuraj Skripsky <js@hotfeet.ch>
Wed, 4 Apr 2007 13:54:51 +0000 (13:54 -0000)
        * FormsAuthenticationModule.cs: Move initialization of _config out
        of Init() as app.Context is null in that method when a session is
        about to be terminated.

svn path=/trunk/mcs/; revision=75387

mcs/class/System.Web/System.Web.Security/ChangeLog
mcs/class/System.Web/System.Web.Security/FormsAuthenticationModule.cs

index a8a9397b139b96aa582d358a0e46322becac964b..ebad1e8b177106b3f6b8c5a9c0474395a56cda57 100644 (file)
@@ -1,3 +1,9 @@
+2007-04-04 Juraj Skripsky <js@hotfeet.ch>
+
+       * FormsAuthenticationModule.cs: Move initialization of _config out
+       of Init() as app.Context is null in that method when a session is
+       about to be terminated.
+
 2007-03-21 Vladimir Krasnov <vladimirk@mainsoft.com>
 
        * AnonymousIdentificationModule.cs: optimized Config property
index edce20281ac015d159fb46b2dbaed99a9fae973d..c68a3aa2de29a46a54c9ac5c57f3a949be17030a 100644 (file)
@@ -44,6 +44,20 @@ namespace System.Web.Security
 #else
                AuthConfig _config = null;
 #endif
+               bool isConfigInitialized = false;
+               
+               private void InitConfig (HttpContext context)
+               {
+                       if(isConfigInitialized)
+                               return;
+#if NET_2_0
+                       _config = (AuthenticationSection) WebConfigurationManager.GetSection ("system.web/authentication");
+#else
+                       _config = (AuthConfig) context.GetConfig ("system.web/authentication");
+#endif
+                       isConfigInitialized = true;
+               }
+
                [SecurityPermission (SecurityAction.Demand, UnmanagedCode = true)]
                public FormsAuthenticationModule ()
                {
@@ -57,11 +71,6 @@ namespace System.Web.Security
                {
                        app.AuthenticateRequest += new EventHandler (OnAuthenticateRequest);
                        app.EndRequest += new EventHandler (OnEndRequest);
-#if NET_2_0
-                       _config = (AuthenticationSection) WebConfigurationManager.GetSection ("system.web/authentication");
-#else
-                       _config = (AuthConfig) app.Context.GetConfig ("system.web/authentication");
-#endif
                }
 
                void OnAuthenticateRequest (object sender, EventArgs args)
@@ -74,6 +83,7 @@ namespace System.Web.Security
                        string loginPage;
                        bool slidingExpiration;
 
+                       InitConfig (context);
                        if (_config == null || _config.Mode != AuthenticationMode.Forms) {
                                return;
                        }
@@ -157,6 +167,7 @@ namespace System.Web.Security
                                return;
 
                        string loginPage;
+                       InitConfig (context);
 #if NET_2_0
                        loginPage = _config.Forms.LoginUrl;
 #else