stighy
stighy

Reputation: 7170

ASP.NET, IIS 6 and url rewriting

i've bought a shared hosting on a windows hoster with IIS 6.

I would like to know how to rewrite url.

I can't modify anything on the server, the only thing i can do is to use ... my asp.net code ! some advice ?

Thanks!

Upvotes: 1

Views: 1721

Answers (1)

Eduardo Molteni
Eduardo Molteni

Reputation: 39413

As the ScottGu blog suggests, you can

1. Do the rewrite manually using the HttpContext.RewritePath() method that ASP.NET provides

void Application_BeginRequest(object sender, EventArgs e) {

    string fullOrigionalpath = Request.Url.ToString();

    if (fullOrigionalpath.Contains("/Products/Books.aspx")) {
        Context.RewritePath("/Products.aspx?Category=Books");
    }
    else if (fullOrigionalpath.Contains("/Products/DVDs.aspx")) {
        Context.RewritePath("/Products.aspx?Category=DVDs");
    }
} 

2. Use a HttpModule
Using a HttpModule (such as urlrewriter.net) does not require any changes on the server, only some changes on Web.Config and deploying the module DLLs

Upvotes: 1

Related Questions