Hi,
I am using URLRewriter it is working fine, As you can see in web config file 'ViewPost.aspx' is being used to rewrite url to display article. Now i need one more page 'ViewPost2.aspx' for the same. how it is possible?
http://urlrewriter.net/[
^]
in web web-config file
<rewriter>
<rewrite url="(.+)-(.+).aspx" to="~/ViewPost.aspx?id=$2"/>
</rewriter>
Generating URL.
<asp:HyperLink ID="hlTitle" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"sub")%>'
NavigateUrl='<%#GenerateURL(DataBinder.Eval(Container.DataItem,"sub"),DataBinder.Eval(Container.DataItem,"Id"))%>'></asp:HyperLink>
in code behind.
public static string GenerateURL(object Title, object strId)
{
string strTitle = Title.ToString();
#region Generate SEO Friendly URL based on Title
strTitle = strTitle.Trim();
strTitle = strTitle.Trim('-');
strTitle = strTitle.ToLower();
char[] chars = @"$%#@!*?;:~`+=()[]{}|\'<>,/^&"".".ToCharArray();
strTitle = strTitle.Replace("c#", "C-Sharp");
strTitle = strTitle.Replace("vb.net", "VB-Net");
strTitle = strTitle.Replace("asp.net", "Asp-Net");
strTitle = strTitle.Replace(".", "-");
for (int i = 0; i < chars.Length; i++)
{
string strChar = chars.GetValue(i).ToString();
if (strTitle.Contains(strChar))
{
strTitle = strTitle.Replace(strChar, string.Empty);
}
}
strTitle = strTitle.Replace(" ", "-");
strTitle = strTitle.Replace("--", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("-----", "-");
strTitle = strTitle.Replace("----", "-");
strTitle = strTitle.Replace("---", "-");
strTitle = strTitle.Replace("--", "-");
strTitle = strTitle.Trim();
strTitle = strTitle.Trim('-');
#endregion
strTitle = strTitle + "-" + strId + ".aspx";
return strTitle;
}
Full Reference: code i took from here.
http://dotnetguts.blogspot.ae/2008/07/url-rewriting-with-urlrewriternet.html[
^]