Esempio n. 1
0
//		public override bool IsSecure()
//		{
//			return base.IsSecure ();
//		}

//		public override string MachineConfigPath
//		{
//			get
//			{
//				string value = base.MachineConfigPath;
//				return value;
//			}
//		}
//
//		public override string MachineInstallDirectory
//		{
//			get
//			{
//				string value = base.MachineInstallDirectory;
//				return value;
//			}
//		}

        /// <summary>
        /// Maps the virtual path to a physical path
        /// </summary>
        /// <param name="virtualPath"></param>
        /// <returns></returns>
        public override string MapPath(string virtualPath)
        {
            String mappedPath = String.Empty;

            if (virtualPath == null || virtualPath.Length == 0 || virtualPath.Equals("/"))
            {
                // asking for the site root
                if (_aspHost.VirtualDirectory == "/")
                {
                    // app at the site root
                    mappedPath = _aspHost.PhysicalDirectory;
                }
                else
                {
                    // unknown site root - don't point to app root to avoid double config inclusion
                    mappedPath = Environment.SystemDirectory;
                }
            }
            else if (_aspHost.IsVirtualPathAppPath(virtualPath))
            {
                // application virtualPath
                mappedPath = _aspHost.PhysicalDirectory;
            }
            else if (_aspHost.IsVirtualPathInApp(virtualPath))
            {
                // inside app but not the app virtualPath itself
                mappedPath = _aspHost.PhysicalDirectory + virtualPath.Substring(_aspHost.NormalizedVirtualPath.Length);
            }
            else
            {
                // outside of app -- make relative to app virtualPath
                if (virtualPath.StartsWith("/"))
                {
                    mappedPath = _aspHost.PhysicalDirectory + virtualPath.Substring(1);
                }
                else
                {
                    mappedPath = _aspHost.PhysicalDirectory + virtualPath;
                }
            }

            mappedPath = mappedPath.Replace('/', '\\');

            if (mappedPath.EndsWith("\\") && !mappedPath.EndsWith(":\\"))
            {
                mappedPath = mappedPath.Substring(0, mappedPath.Length - 1);
            }

            return(mappedPath);
        }