How to Get PageName from URL

Akshayblevel
Posted by Akshayblevel under C# category on | Points: 40 | Views : 1760
public static string GetPageName(string URL)
{
string url = URL;
char[] patt = { '/' };
char[] p = { '.' };
string[] arr = url.Split(patt);
url = arr[arr.Length - 1];
url = url.Remove(url.IndexOf('.'));
return url;
}

Comments or Responses

Posted by: Sheonarayan on: 8/7/2012 Level:HonoraryPlatinum | Status: [Administrator] | Points: 10
I think this is the easiest way perhaps

 string url = "http://www.dotnetfunda.com/articles/showArticle.aspx";

string pageName = System.IO.Path.GetFileName(url);


Thanks

Login to post response