In our CMS System, Disill, we are using http modules for url rewriting, creating human readable url from the sitemap defined in the system. There we are using the HttpContext.RewritePath to rewrite the path to the .aspx page template. In version 1.0 of the framework the RewritePath worked fine, for 3-4 times and then started giving me a 404 error when I was calling it like this
Context.RewritePath(target.ToString());
Where target is a StringBuilder object containing the path to the real .aspx including a querystring (~/templates/frontpage.aspx?bleh=blah&foo=bar), After a while lot of debugging and pulling most of me hair out. I discovered that this function worked fine if the original request did not have an empty querystring, resulting in "?." being appended to the end of all URL paths in the system.
After I upgraded to 2003 and started compiling using version 1.1 of the framework, I saw a overload of the RewritePath that looked like this
public void RewritePath(string filePath, string pathInfo, string queryString);
The first thing a spotted there was that the filepath and the querystring are separate string, maybe this could be the thing I was looking for all the time. I rewrote my single line of code so that it looks like this:
Context.RewritePath(target.ToString(), Context.Request.PathInfo, querystring.ToString());
Tried calling the dev setup without a query string, ok, it worked, hit F5 a couple of times (where it usually would break), everything worked. Thought to myself: "this is to good to be true, I'll start the Microsoft Application Center Test and put it under some pressure". Zero errors. Finally, I'll be able to publish clean path (e.g. looking like /frontpage/subpage/blah/foo/bar instead of /frontpage/subpage/blah/bar/view.aspx?., note the view.aspx thing is a whole other subject)
I'm sure this post will get lost in all the PDC frenzy going on right now but here goes.
Since this is my first post I think it's tradition to introduce myself. My Name is Oddur Magnusson, I'm 22 years old and happen to live in the small island known as Iceland. I've been doing .net development since beta 1, mainly focusing on the asp.net development. My company Atom01(icelandic only) mainly focuses on CMS development using .net, where I happen to lead the way.
I hope to be able to contribute some great stuff to this blog, mostly tips and tricks and real life adventures from the .net frontier.
Thanks to GisliO, our local .net baldie, for pointing me in the right direction getting a blog here