System.Web.HttpRequest.SetFilePath C# (CSharp) Method

SetFilePath() private method

private SetFilePath ( string path ) : void
path string
return void
		internal void SetFilePath (string path)
		{
			file_path = path;
			physical_path = null;
			original_path = null;
		}

Usage Example

Example #1
0
        void RewritePath(string filePath, string pathInfo, string queryString, bool setClientFilePath)
        {
            if (filePath == null)
            {
                throw new ArgumentNullException("filePath");
            }
            if (!VirtualPathUtility.IsValidVirtualPath(filePath))
            {
                throw new HttpException("'" + HttpUtility.HtmlEncode(filePath) + "' is not a valid virtual path.");
            }

            bool        pathRelative = VirtualPathUtility.IsAppRelative(filePath);
            bool        pathAbsolute = pathRelative ? false : VirtualPathUtility.IsAbsolute(filePath);
            HttpRequest req          = Request;

            if (req == null)
            {
                return;
            }

            if (pathRelative || pathAbsolute)
            {
                if (pathRelative)
                {
                    filePath = VirtualPathUtility.ToAbsolute(filePath);
                }
                else
                {
                    filePath = filePath;
                }
            }
            else
            {
                filePath = VirtualPathUtility.AppendTrailingSlash(req.BaseVirtualDir) + filePath;
            }

            if (!StrUtils.StartsWith(filePath, HttpRuntime.AppDomainAppVirtualPath))
            {
                throw new HttpException(404, "The virtual path '" + HttpUtility.HtmlEncode(filePath) + "' maps to another application.", filePath);
            }

            req.SetCurrentExePath(filePath);
            req.SetFilePath(filePath);

            if (setClientFilePath)
            {
                req.ClientFilePath = filePath;
            }

            // A null pathInfo or queryString is ignored and previous values remain untouched
            if (pathInfo != null)
            {
                req.SetPathInfo(pathInfo);
            }

            if (queryString != null)
            {
                req.QueryStringRaw = queryString;
            }
        }
All Usage Examples Of System.Web.HttpRequest::SetFilePath