Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 14393 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > C# > How to Get PageName from URL ...
Akshayblevel

How to Get PageName from URL

 Code Snippet posted by: Akshayblevel | Posted on: 8/6/2012 | Category: C# Codes | Views: 783 | Status: [Member] | Points: 40 | Alert Moderator   
Ads

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;
}
Found interesting? Add this to:


 Responses

Sheonarayan
Posted by: Sheonarayan | Posted on: 8/7/2012 | Level: HonoraryPlatinum | Status: [Microsoft_MVP] [Administrator] | Points: 10 | Alert Moderator 

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

Regards,
Sheo Narayan, Microsoft MVP
The Founder
http://www.dotnetfunda.com

>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 6/19/2013 5:31:14 PM