[Mono-list] ASP.NET Checking if File Exists Error / 404 on Rewrite
Robert Jordan
robertj at gmx.net
Sun Mar 8 14:17:01 EDT 2009
Shauki Bagdadi wrote:
> Hello!
> Have you found the solution for
> http://lists.ximian.com/pipermail/mono-list/2007-August/036106.html
> May you share it, please!
> Thanks.
You can either use an apache rewrite rule (if you're using
apache, of course):
http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide.html
Or hook HttpApplication's
BeginRequest to route the request to another file:
global.asax:
protected void Application_BeginRequest (object sender, EventArgs e)
{
// map inexistent files to "bar.aspx"
if (!File.Exists (Request.PhysicalPath))
Context.RewritePath ("/appname/bar.aspx");
}
or this
protected void Application_BeginRequest (object sender, EventArgs e)
{
map "foo.aspx" to "bar.aspx".
if (Request.FilePath == "/appname/foo.aspx")
Context.RewritePath ("/appname/bar.aspx");
}
Robert
More information about the Mono-list
mailing list