Jan
23
2007
Url rewriting - Cannot use a leading to exit above the top directory
Posted by admin under
ASP.NET 2.0

I am using Google sitemaps to see that my sites are getting indexed without trouble. And - believe me or not - after creating a new site and creating the sitemap (article on that will follow) - I saw that google could only read the index page - not the pages below.
After looking in my serverlog I saw that - yes when google visited the server indeed did respond with Server Error 500 = Internal server error.
The event viewer told me more:
Exception information:
Exception type: HttpException
Exception message: Cannot use a leading .. to exit above the top directory.
Request information:
Request URL: http://www.futurehockeystars.com/article.aspx?pid=5&artid=1637
In short - when google visited it was getting a weird error - and I never got the error. Tried with different borwsers etc but never able to reproduce I almost couldn't believe it but finally I found the answer (using google of course :) ).
Get googlebot to crash your .NET 2.0 site
Meaning - when using url rewriting (also I did themes) and RewritePath(newpath, false) this triggers a bug in a special HtmlRender component - which gets used when google visits the site ( depending on the user agent ASP.NET runtime uses different html rendering engines).
In my 1.1 sites I always rewrite the action url on my Form tag to the rewritten path - however on this particular site I didn't need to, or should I say I was lazy - I didn't care if the form action="" contained the rewritten path or not. And that path got rendered with a ..\ to much.
So the easy way out - I read Scott Mitchells article on URL Rewriting - and used his code for skm:form
<%@ Register TagPrefix="skm" Namespace="ActionlessForm"
Assembly="FutureHockeyStars" %>
...
...
...
<skm:form id="form1" runat="server">
...
...
</skm:form>
Cause for some reason my ownHtmlForm derived class - which I use to solve the same problem in 1.1 didn't work.