equivalent for ModRewrite

A

Alexander Widera

hi,

perhaps you all know ModRewrite for the apache webserver... Is there an
equivalent for asp.net / iis? I don't want to buy a component (.dll)... I
want to program it myself. Some time ago, I wrote it with an custom
errorpage for error 404 which redirects it to the correct page. Perhaps
there is an simplier / better way?
Thanks for help, Alex
 
A

Alexander Widera

I tried a simple context.RewriteUrl("..."); but if I call an url (which
doesn't exists) i get an error message.

The complete code look like this (placed in the global.asax)

void Application_BeginRequest(object sender, EventArgs e)
{
HttpRequest request = ((HttpApplication) sender).Request;
HttpContext context = ((HttpApplication)sender).Context;
string applicationPath = request.ApplicationPath;
if(applicationPath == "/"){
applicationPath = string.Empty;
}
string path =
request.Url.AbsolutePath.Substring(applicationPath.Length);
context.RewritePath("/default.aspx");
}

I think this code should redirect every request to /defaut.aspx, or am i
wrong?
But I get the error: 404, page cannot be found.

What might by the problem?

Thanks for help,

Alex
 
A

Alexander Widera

that's what I tried (in a shorter way :)), i tried this code too, but i get
the same Error.... if I call an non existing file in the filesystem....
404 not found... If the page exists, then the redirection works.
 
A

Alexander Widera

Ahh... now I understand.... You were right... If the "nonexisting-file" ends
with .aspx then it works ... but not if it ends with .html for example...
Is there a possibility that this works too with the ending .html except
adding .html to the list of interpreted extensions of the aspx-engine.

Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top