Comment obtenir le chemin de l'URL en C #

Je veux obtenir tous les le chemin de l'URL à l'exception de la page de l'url, par exemple: mon URL est http://www.MyIpAddress.com/red/green/default.aspx je veux obtenir "http://www.MyIpAddress.com/red/green/". Comment puis-je obtenir.Je suis en train de faire comme

string sPath = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).OriginalString; System.Web.HttpContext.Current.Request.Url.AbsolutePath;
            sPath = sPath.Replace("http://", "");
            System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
            string sRet = oInfo.Name;
            Response.Write(sPath.Replace(sRet, ""));

Son montrant exception sur le nouveau Système.IO.FileInfo(sPath) sPath contenir "localhost/rouge/vert/par défaut.aspx" en disant: "Le chemin du format n'est pas pris en charge."

source d'informationauteur Nomi Ali