ソースを参照

* Control.cs: New method for resolving urls that use ~/ to denote
the applications base directory.

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

Jackson Harper 22 年 前
コミット
8ecdf4a863

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

@@ -1,3 +1,8 @@
+2003-11-19  Jackson Harper <[email protected]>
+
+	* Control.cs: New method for resolving urls that use ~/ to denote
+	the applications base directory.
+	
 2003-11-19  Jackson Harper <[email protected]>
 
 	* TemplateParser.cs: Fix typo in error message.

+ 12 - 1
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -723,7 +723,18 @@ namespace System.Web.UI
 			
 			HttpResponse resp = Context.Response;
 			return resp.ApplyAppPathModifier (UrlUtils.Combine (ts, relativeUrl));
-                }
+		}
+
+		internal string ResolveBaseUrl (string url)
+		{
+			if (url [0] != '~')
+				return url;
+			if (url.Length < 2 || (url.Length == 2 && url [1] == '/'))
+				return Context.Request.BaseVirtualDir;
+			if (url [1] == '/')
+				return UrlUtils.Combine (Context.Request.BaseVirtualDir, url.Substring (2));
+			return url;
+		}
 
 		[EditorBrowsable (EditorBrowsableState.Advanced)]
                 public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT