ASP.NET CoreASP.NET MVCC#

Create SEO friendly URL Slug in C#

Below points implemented in code

  • Created Urlhelper class
  • Created method GenerateSeoFriendlyURL
  • Pass string to created method
  • Create Regex object with keywords.
  • Add name space usingText.RegularExpressions;
  • Use regex.Replace to string
  • Convert string to lowercase
  • Remove spaces from left and right from string
  • Remove combined hyphen if more than one
Tags
Show More

Leave a Reply

Your email address will not be published. Required fields are marked *

Close