RewritePath method not working correctly
I'm running a the following code snippet in Global.asax:
public void Application_BeginRequest(object sender, EventArgs e)
currentPath = Request.Path.ToLower();
if(currentPath.IndexOf("/news/") > 0 &&
System.IO.Path.GetExtension(currentPath) == ".aspx")
the request is within the /NEWS/ directory, so re-write the URL
to appear to be a filename, rather than a URL with a query string.
user-visible URL: http://www.domain.com/news/1950.aspx
actual URL: http://www.domain.com/news/story.aspx?headline=1950
Essentially, it's disguising URLs to make things a little easier to
remember. I use thie by placing several anchor tags <a href...> on a page
that point to a URL like http://www.domain.com/news/4578.aspx and the
proper URL is loaded in the background, and the user is none the wiser.
However, it's not working as it should. On my production machine at home,
it does as planned, but browsing to a URL like
http://www.domain.com/news/4578.aspx gets a 404 error, thinking the file is
actually one on disk. In short, it tries to browse directly for the file
Does it matter if the server I'm on is running ASP.NET 1.0 server or 1.1?
I'm using 1.0 on my home development machine and my host is using 1.1. Or
does it matter, meaning both are installed and my code should work with
either? I read somewhere that the RewritePath method is a bit different in
1.1 than 1.0, the latter of which my site is written in.
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL