This if
if ((ch >= '0' && ch <= '9') ||
(ch >= 'a' && ch <= 'z'))
means only English numbers and characters are allowed. But Persian characters have a different range:
public static bool ContainsFarsi(string txt)
{
return !string.IsNullOrEmpty(txt) &&
Regex.IsMatch(txt, @"[\u0600-\u06FF]");
}
+
Don't use that ToFriendlyUrl
method. Create an extension method to apply your filtering and then use the standard Html.ActionLink
method and pass your parameters as new route values
or it's better to use the T4MVC HTML helper methods.
By constructing your links manulally, you will lose a lot of features like adjusting the root path based on the current domain or sub domain and also encoding the special characters and many outer built-in features.