[Mono-dev] [PATCH] Login control fixes

Marek Habersack grendel at caudium.net
Tue Apr 25 16:03:54 EDT 2006


Hello everybody,

  The attached patch fixes two problems with the Login control in Mono:

 - As per http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.login.destinationpageurl.aspx
   the patch makes Login redirect the user to destination page, in the
   following precedence:

     - DestinationPageUrl property
     - Referring page
     - Forms authentication defaultUrl
     - The login page itself

 - When the login control is used inside a content placeholder with a master
   page (e.g. http://asp.net/QuickStart/util/srcview.aspx?path=~/aspnet/samples/ctrlref/login/Login.src)
   Mono will throw an exception referring to line 1332 in Login.cs. The
   patch fixes that by checking whether FormsAuthentication.LoginUrl is not
   null. 
   I'm not sure whether the fix is correct, though, since the bug might be
   in FormsAuthentication code. The reason might be that the Initialize
   method of the FormsAuthentication class is not called before
   Login.IsDefaultLoginPage().

best regards,

marek
-------------- next part --------------
--- mcs.orig/class/System.Web/System.Web.UI.WebControls/Login.cs	2006-04-11 16:37:01.218843000 +0200
+++ mcs/class/System.Web/System.Web.UI.WebControls/Login.cs	2006-04-25 21:52:44.698745490 +0200
@@ -1285,8 +1285,13 @@ namespace System.Web.UI.WebControls {
 			OnAuthenticate (aea);
 
 			if (aea.Authenticated) {
+				FormsAuthentication.SetAuthCookie (UserName, RememberMeSet);				
+
 				string url = DestinationPageUrl;
-				FormsAuthentication.SetAuthCookie (UserName, RememberMeSet);
+				if (url.Length == 0 && Page.Request.UrlReferrer != null)
+					url = Page.Request.UrlReferrer.ToString();
+				if (url.Length == 0 && FormsAuthentication.DefaultUrl != null)
+					url = FormsAuthentication.DefaultUrl;
 				if (url.Length == 0) {
 					Redirect (FormsAuthentication.LoginUrl);
 				} else {
@@ -1320,8 +1325,10 @@ namespace System.Web.UI.WebControls {
 		{
 			if ((Page == null) || (Page.Request == null))
 				return false;
-			string url = Page.Request.Url.AbsolutePath;
 			string defaultLogin = FormsAuthentication.LoginUrl;
+			if (defaultLogin == null)
+				return false;
+			string url = Page.Request.Url.AbsolutePath;
 			return (String.Compare (defaultLogin, 0, url, url.Length - defaultLogin.Length, defaultLogin.Length,
 				true, CultureInfo.InvariantCulture) == 0);
 		}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20060425/920d8a2c/attachment.bin 


More information about the Mono-devel-list mailing list