How can I go about generating a Friendly URL in C#? Currently I simple replace spaces with an underscore, but how would I go about generating URL\'s like Stack Overflow?
here is a simple function which can convert your string to Url, you just need to pass title or string it will convert it to user friendly Url.
public static string GenerateUrl(string Url)
{
string UrlPeplaceSpecialWords = Regex.Replace(Url, @""|['"",&?%\.!()@$^_+=*:#/\\-]", " ").Trim();
string RemoveMutipleSpaces = Regex.Replace(UrlPeplaceSpecialWords, @"\s+", " ");
string ReplaceDashes = RemoveMutipleSpaces.Replace(" ", "-");
string DuplicateDashesRemove = ReplaceDashes.Replace("--", "-");
return DuplicateDashesRemove.ToLower();
}