Author:

I am a web developer. I work on JavaScript, PHP, ASP.NET, jQuery, ActionScript, AJAX and Facebook application, as well as interested in social networking and daily active user on Twitter, Facebook and Google+
Download Demostration

Here is another version of SEO Friendly URL creation, I had posted already when I used to work in ASP Classic. Lets review short and simple method to create SEO Friendly URL in ASP.NET.

C# Method/Function

public string createSEOTitle(string m_strText)
{
	//m_strURL = m_strURL.Replace("&", "and");
	m_strText = Regex.Replace(m_strText, @"[^\w]", "-");
	do
	{
		m_strText = m_strText.Replace("--", "-");
	} while (m_strText.Contains("--"));

	if (m_strText.EndsWith("-"))
		m_strText = m_strText.Substring(0, m_strText.Length - 1);

	if (m_strText.StartsWith("-"))
		m_strText = m_strText.Substring(1, m_strText.Length - 1);

	return m_strText.ToLower();
}

I hope it is also would be helpful..

Thank you,


Kick It on DotNetKicks.com   Shout it  

Popularity: 5%

Comments on this entry (3 comments)

Did you like this post? You can share your opinion with us! Simply click here.

Shahid

You should have included a demo page to show how exactly this looks like…

Reply

Shahid,

I have uploaded sample files and demo page as well. You can check demonstration of SEO Friendly URL which will remove all symbols and bad words from text.

Thank you,

Add Your Comment