Parsing URL
Function to Parses a URL and returns the final '.aspx' name
CODE:
public static string ParseWebPage(string Web_Page_Name)
{
try
{
Web_Page_Name = Web_Page_Name.Replace("/CommAdmin/", "/").Replace("/CommAdmin_1/", "/").Replace("/CommAdmin2/", "/");
// Dimension variables to make easy references
string strLower = Web_Page_Name.ToLower();
// Cut off the protocol
if (strLower.IndexOf("http://") == 0)
Web_Page_Name = Web_Page_Name.Substring(("http://").Length);
else if (strLower.IndexOf("https://") == 0)
Web_Page_Name = Web_Page_Name.Substring(("https://").Length);
else if (strLower.IndexOf("ftp://") == 0)
Web_Page_Name = Web_Page_Name.Substring(("ftp://").Length);
// Get new string
strLower = Web_Page_Name.ToLower().Substring(Web_Page_Name.IndexOf("/") + 1);
Web_Page_Name = Web_Page_Name.Substring(Web_Page_Name.IndexOf("/") + 1);
Web_Page_Name = Web_Page_Name.Substring(0, strLower.IndexOf(".asp") + 5);
return Web_Page_Name.Replace("/", "/
");
}
catch
{
return string.Empty;
}
}
0 comments:
Post a Comment