示例#1
0
        public string GetAbsolutePath(string executingFilePath, string pagePath)
        {
            if (string.IsNullOrEmpty(pagePath))
            {
                // Path is not valid; no change required.
                return(pagePath);
            }

            if (IsApplicationRelativePath(pagePath))
            {
                // An absolute path already; no change required.
                return(pagePath);
            }

            if (!IsRelativePath(pagePath))
            {
                // A page name; no change required.
                return(pagePath);
            }

            if (string.IsNullOrEmpty(executingFilePath))
            {
                // Given a relative path i.e. not yet application-relative (starting with "~/" or "/"), interpret
                // path relative to currently-executing view, if any.
                // Not yet executing a view. Start in app root.
                var absolutePath = "/" + pagePath;
                return(PublicViewEnginePath.ResolvePath(absolutePath));
            }

            return(PublicViewEnginePath.CombinePath(executingFilePath, pagePath));
        }