Răsfoiți Sursa

2008-06-04 Marek Habersack <[email protected]>

	* SessionStateModule.cs: set the application modifier path to bare
	session id.

2008-06-04  Marek Habersack  <[email protected]>

	* UrlUtils.cs: added internal method HasSessionId

2008-06-04  Marek Habersack  <[email protected]>

	* SessionStateModule.cs: set application path modifier string to
	the bare session ID.

2008-06-04  Marek Habersack  <[email protected]>

	* HttpResponse.cs: correctly modify virtual path to include the
	session ID in cookieless session mode. Fixes bug #396628.

svn path=/trunk/mcs/; revision=104861
Marek Habersack 17 ani în urmă
părinte
comite
ae00a7ec53

+ 5 - 0
mcs/class/System.Web/System.Web.SessionState/ChangeLog

@@ -1,3 +1,8 @@
+2008-06-04  Marek Habersack  <[email protected]>
+
+	* SessionStateModule.cs: set application path modifier string to
+	the bare session ID.
+
 2008-05-30  Marek Habersack  <[email protected]>
 
 	* SessionStateModule.cs: do not use synthetized event accessors

+ 1 - 1
mcs/class/System.Web/System.Web.SessionState/SessionStateModule.cs

@@ -165,7 +165,7 @@ namespace System.Web.SessionState
 			string new_path = UrlUtils.RemoveSessionId (base_path, context.Request.FilePath);
 			context.Request.SetFilePath (new_path);
 			context.Request.SetHeader (HeaderName, id);
-			context.Response.SetAppPathModifier (String.Concat ("(", id, ")"));
+			context.Response.SetAppPathModifier (id);
 		}
 		
 		void OnReleaseRequestState (object o, EventArgs args)

+ 5 - 0
mcs/class/System.Web/System.Web.SessionState_2.0/ChangeLog

@@ -1,3 +1,8 @@
+2008-06-04  Marek Habersack  <[email protected]>
+
+	* SessionStateModule.cs: set the application modifier path to bare
+	session id.
+
 2008-05-30  Marek Habersack  <[email protected]>
 
 	* SessionStateModule.cs: do not use synthetized event accessors

+ 1 - 1
mcs/class/System.Web/System.Web.SessionState_2.0/SessionStateModule.cs

@@ -204,7 +204,7 @@ namespace System.Web.SessionState
 			string new_path = UrlUtils.RemoveSessionId (base_path, context.Request.FilePath);
 			context.Request.SetFilePath (new_path);
 			context.Request.SetHeader (HeaderName, id);
-			context.Response.SetAppPathModifier (String.Concat ("(", id, ")"));
+			context.Response.SetAppPathModifier (id);
 		}
 
 		void OnAcquireRequestState (object o, EventArgs args) {

+ 4 - 0
mcs/class/System.Web/System.Web.Util/ChangeLog

@@ -1,3 +1,7 @@
+2008-06-04  Marek Habersack  <[email protected]>
+
+	* UrlUtils.cs: added internal method HasSessionId
+
 2007-12-12  Marek Habersack  <[email protected]>
 
 	* SettingsMappingManager.cs: use the 'settings.map.config' name

+ 8 - 0
mcs/class/System.Web/System.Web.Util/UrlUtils.cs

@@ -73,6 +73,14 @@ namespace System.Web.Util {
 			return path.Substring (2, SessionId.IdLength);
 		}
 
+		internal static bool HasSessionId (string path)
+		{
+			if (path == null || path.Length < 5)
+				return false;
+
+			return (StrUtils.StartsWith (path, "/(") && path.IndexOf ("/)") > 2);
+		}
+		
 		internal static string RemoveSessionId (string base_path, string file_path)
 		{
 			// Caller did a GetSessionId first

+ 3 - 0
mcs/class/System.Web/System.Web/ChangeLog

@@ -1,5 +1,8 @@
 2008-06-04  Marek Habersack  <[email protected]>
 
+	* HttpResponse.cs: correctly modify virtual path to include the
+	session ID in cookieless session mode. Fixes bug #396628.
+
 	* HttpServerUtility.cs: remove session hash from the URL if in the
 	cookieless mode. Fixes bug #396628.
 

+ 18 - 9
mcs/class/System.Web/System.Web/HttpResponse.cs

@@ -40,6 +40,8 @@ using System.Web.Configuration;
 using System.Globalization;
 using System.Security.Permissions;
 using System.Web.Hosting;
+using System.Web.Configuration;
+using System.Web.SessionState;
 
 namespace System.Web {
 	
@@ -507,21 +509,28 @@ namespace System.Web {
 		
 			if (virtualPath == "")
 				return context.Request.RootVirtualDir;
-		
+
 			if (UrlUtils.IsRelativeUrl (virtualPath)) {
 				virtualPath = UrlUtils.Combine (context.Request.RootVirtualDir, virtualPath);
 			} else if (UrlUtils.IsRooted (virtualPath)) {
 				virtualPath = UrlUtils.Canonic (virtualPath);
 			}
-		
+
+			bool cookieless = false;
+#if NET_2_0
+			SessionStateSection config = WebConfigurationManager.GetSection ("system.web/sessionState") as SessionStateSection;
+			cookieless = SessionStateModule.IsCookieLess (context, config);
+#else
+			SessionConfig config = HttpContext.GetAppConfig ("system.web/sessionState") as SessionConfig;
+			cookieless = config.CookieLess;
+#endif
+			if (!cookieless)
+				return virtualPath;
+
 			if (app_path_mod != null && virtualPath.IndexOf (app_path_mod) < 0) {
-				string rvd = context.Request.RootVirtualDir;
-				string basevd = rvd.Replace (app_path_mod, "");
-		
-				if (!StrUtils.StartsWith (virtualPath, basevd))
-					return virtualPath;
-		
-				virtualPath = UrlUtils.Combine (rvd, virtualPath.Substring (basevd.Length));
+				if (UrlUtils.HasSessionId (virtualPath))
+					virtualPath = UrlUtils.RemoveSessionId (VirtualPathUtility.GetDirectory (virtualPath), virtualPath);
+				return UrlUtils.InsertSessionId (app_path_mod, virtualPath);
 			}
 		
 			return virtualPath;