url rewriting - build paths

Posted by Cristian Boariu on Stack Overflow See other posts from Stack Overflow or by Cristian Boariu
Published on 2010-06-05T07:44:24Z Indexed on 2010/06/05 7:52 UTC
Read the original article Hit count: 225

Filed under:
|
|

Hi guys,

I have started to work on a site without url rewriting. Now, the request is to use friendly urls so i started to use Intelligencia.UrlRewriter.

Let's take an example:

I have a method:

 public static string getCategoriesIndexLink(string category)
{
    string baseUrl = getBaseUrl() + (String)HttpContext.GetGlobalResourceObject("Paths", "categorii.index");
    return baseUrl.AddQueryParam(CQueryStringParameters.CATEGORY, category);
}

which build this kind of urls

"~/Site/Categorii.aspx?category=$1"

Now i've added the following rule in web.config:

<rewrite url="~/Site/Categorii/(.+)" to="~/Site/Categorii.aspx?category=$1" />

The question is HOW i can make the above method to build that kind of nice url? So no longer return

 "~/Site/Categorii.aspx?category=m1"

but

"~/Site/Categorii/m1"

without beeing needed to modify its structure?

I mean, i have about 30 methods like the one from the above; it would be extremely helpfull if i can be guided to use a regex at the output of the methods iso modifying the url construction...

Thanks in advance...

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET