G
Greg Collins [Microsoft MVP]
I have done a bit of research of Url Rewriting, but as yet have been unsuccessful at getting it to work well, and there are issues around what file types are supported and how much code you want to write.
While working on a similar, though partially unrelated, issue, I came across a possible alternate method. Before I pursue this method in full, I wanted to get opinions of others as to any unforseen issues I might encounter.
The method is this:
In IIS, replace the default 404 error page with a custom ASPX page. Make sure you don't try to process any errors in the web.config.
When a 404 is hit, the custom ASPX page is called. Although to the user, the URL they typed in is still visible, the ASPX page is now loaded, and the QueryString contains the original url typed in.
So if I type in:
http://localhost/some_path
I get redirected to my custom ASPX page with a QueryString containing:
404;http://localhost:80/some_path
This query string is encoded--so it must be decoded first to be useful. Also note that it added the port ":80" to the host name.
In my custom ASPX page, I can now parse this url and do my Url Rewriting. If an unknown url is encountered, I pass to an error page.
To me this is much easier and more elegant than trying to do Url Rewriting in other ways.
So my questions are:
* Has anyone else tried this, or is currently using this?
* Are there unforseen issues I will encounter with this approach?
While working on a similar, though partially unrelated, issue, I came across a possible alternate method. Before I pursue this method in full, I wanted to get opinions of others as to any unforseen issues I might encounter.
The method is this:
In IIS, replace the default 404 error page with a custom ASPX page. Make sure you don't try to process any errors in the web.config.
When a 404 is hit, the custom ASPX page is called. Although to the user, the URL they typed in is still visible, the ASPX page is now loaded, and the QueryString contains the original url typed in.
So if I type in:
http://localhost/some_path
I get redirected to my custom ASPX page with a QueryString containing:
404;http://localhost:80/some_path
This query string is encoded--so it must be decoded first to be useful. Also note that it added the port ":80" to the host name.
In my custom ASPX page, I can now parse this url and do my Url Rewriting. If an unknown url is encountered, I pass to an error page.
To me this is much easier and more elegant than trying to do Url Rewriting in other ways.
So my questions are:
* Has anyone else tried this, or is currently using this?
* Are there unforseen issues I will encounter with this approach?