I am trying to build a system so that links are always to a nice folder path
instead of links that use query strings. (My site will have dynamically
generated paths).
I'm not sure how to rewrite the path, but I think I figured out how to solve
the problem.
Just to recap,
www.mydomain.com/users/ is a real path in my project.
www.mydomain.com/users/BobSmith/ is not (there's no "BobSmith" folder on my
server. If a user tries to browse to
www.mydomain.comi/users/BobSmith, I
want that URL to stay displayed in their IE address bar, but I want the
actual content they see to be produced by the .aspx page at
www.mydomain.com/users/Default.aspx.
I tried using the customErrors element in my web.config file to create a
redirect for 404 errors. It almost works - the user sees the content
produced by
www.mydomain.com/users/Default.aspx, but the path in the IE
address bar is
http://www.mydomain.com/users/Defaul...Users/BobJones.
I found that if instead of using the customErrors in my web.config file, I
just set up a custom error (for error 404) in IIS, then the URL displayed in
the user's browser is the desired,
www.mydomain.com/users/BobSmith/, but the
content is created by
www.mydomain.com/users/default.aspx. So the moral of
the story in this case seems to be to not use the web.config file to set up
custom error handling - I have to use IIS for this instead.
But, if there is a way to do what I want using the web.config file
customErrors element, I'd love to know how.