Cannot use a leading .. to exit above the top directory

Topics: ASP.NET 2.0, Business Logic Layer
Sep 7, 2007 at 11:59 PM
Hi,
I am using BlogEngine.net in my blog http://www.bloggingdeveloper.com. Today, I integrate ELMAH to my site. And I noticed that, when GoogleBot or Slurp enters to posts (e.g: http://www.bloggingdeveloper.com/post/Absolutely-Pluggable-Application-Wide-Error-Logging-Facility-for-ASPNET-Web-Applications---ELMAH.aspx), it receives the following error "Cannot use a leading .. to exit above the top directory".

So, I googled the web and find the reason of the error. But I haven't come with a reasonable solution. So, I entered the UrlRewrite.cs and changed all rebaseClientPath from false to true.

I think, it is a very important problem because search engines cannot crawl posts.

Thanks in advance for all your helps.
blogging developer
Sep 8, 2007 at 4:28 PM
What code did you change in the utils.cs file? I am noticing the same thing on my event logs on my hosting server.


bloggingdeveloper wrote:
Hi,
I am using BlogEngine.net in my blog http://www.bloggingdeveloper.com. Today, I integrate ELMAH to my site. And I noticed that, when GoogleBot or Slurp enters to posts (e.g: http://www.bloggingdeveloper.com/post/Absolutely-Pluggable-Application-Wide-Error-Logging-Facility-for-ASPNET-Web-Applications---ELMAH.aspx), it receives the following error "Cannot use a leading .. to exit above the top directory".

So, I googled the web and find the reason of the error. But I haven't come with a reasonable solution. So, I entered the UrlRewrite.cs and changed all rebaseClientPath from false to true.

I think, it is a very important problem because search engines cannot crawl posts.

Thanks in advance for all your helps.
blogging developer


Sep 8, 2007 at 11:09 PM
I changed the UrlRewrite.cs. I changed the every context.RewritePath's last parameter from false to true.

Now I dont receive errors but, I may broke another thing.

Cheers.
Thanks in advance for all your helps.
http://bloggingdeveloper.com
Coordinator
Sep 9, 2007 at 9:28 AM
For a regular installation, this breaks the entire site. I've just tried doing what you suggested.
Sep 9, 2007 at 4:37 PM
so what are the results?
Coordinator
Sep 9, 2007 at 6:38 PM
I don't know at the time. Do you have an idea?
Sep 9, 2007 at 7:00 PM
I don't know. I integrate ELMAH to my site to log errors. After the change, I haven't received any error. However, it is very important to come up with a better solution because search engines can not crawl /post/, /authors/, and /categories/ with the original code. I checked couple of sites using blogengine and noticed that posts of most sites are not indexed with google.

I found couple of articles about the problem but I tried every solution on these articles, and nothing changed.

Here is an article about the problem: http://todotnet.com/archive/0001/01/01/7472.aspx

I now checked the dotnetblogengine.net, and noticed that it's posts were crawled by google. Maybe it is a hosting related problem.

Cheers,
http://www.bloggingdeveloper.com
Coordinator
Sep 9, 2007 at 9:25 PM
There is no problems on blog.madskristensen.dk either. If what that article you refers to is correct, then a very easy fix is to override the render method on the base page to use the HtmlTextWriter instead of the Html32TextWriter. What I don't like about this issue is that it seems to only occur on your and probably a few other BlogEngine.NET installations. Anyway, it must be fixed. Since I can reproduce the error, could I get you to add this code to the BlogBasePage.cs in BlogEngine.Core?

protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter tw)
{
return new XhtmlTextWriter(base.CreateHtmlTextWriter(tw));
}

It should make sure always to render the output as Xhtml and not use the Html32TextWriter. Please try it out and see if it solves the problem.
Sep 10, 2007 at 1:37 AM
Mads, I had the same issue. It was a problem enought lately that I have been having issues with my server performance. I had to add two .brower files for the yahoo!slurp and googlebot. I went to http://www.seoconsultants.com/tools/headers/ and tested my site. They did not work before but worked after the changes. Is this going to be added/changed in the base code or are people going to do it on their own?


madskristensen wrote:
There is no problems on blog.madskristensen.dk either. If what that article you refers to is correct, then a very easy fix is to override the render method on the base page to use the HtmlTextWriter instead of the Html32TextWriter. What I don't like about this issue is that it seems to only occur on your and probably a few other BlogEngine.NET installations. Anyway, it must be fixed. Since I can reproduce the error, could I get you to add this code to the BlogBasePage.cs in BlogEngine.Core?

protected override HtmlTextWriter CreateHtmlTextWriter(TextWriter tw)
{
return new XhtmlTextWriter(base.CreateHtmlTextWriter(tw));
}

It should make sure always to render the output as Xhtml and not use the Html32TextWriter. Please try it out and see if it solves the problem.

Coordinator
Sep 10, 2007 at 1:19 PM
Of course it will be added, but I would much rather see if the snippet I wrote with the XhtmlTextWriter will do the trick instead of .browser files.
Sep 12, 2007 at 8:52 PM
Mads,

I tried the code snippet, you posted. With the code snippet I still get the same error.

May I get the browser files that rclarkson mentioned?

I want to give a try.

Cheers,
http://www.bloggingdeveloper.com
Sep 12, 2007 at 10:33 PM
Here is the file link http://www.romanclarkson.us/post/Cannot-use-a-leading--to-exit-above-the-top-directory-in-BE.aspx. Just add the folder and contents to the root of your BE installation. I ran it for a full day and had no errors with GoogleBot or Slurp. However, as soon as I removed it, error after error after error. We worked a couple of coding overrides in the default.aspx, which is still there in the download as of this post, but it did not take care of the issue. We will do something different. This is not going to be the long view fix.




bloggingdeveloper wrote:
Mads,

I tried the code snippet, you posted. With the code snippet I still get the same error.

May I get the browser files that rclarkson mentioned?

I want to give a try.

Cheers,
http://www.bloggingdeveloper.com


Sep 13, 2007 at 10:00 AM
I inserted the code snippet, upload the browser files and checked with http://www.seoconsultants.com/tools/headers/. I received the error again.
Sep 13, 2007 at 1:23 PM
Edited Sep 13, 2007 at 1:27 PM
Strange. I was only using the App_Broswer files and everything worked fine. I am finding a couple of errors like this in my event log. I have eleven of them within a minute of each other starting this morning CDT. The seo website says my site is fine on my root url. However, http://www.romanclarkson.us/post/The-easiest-XML-Role-Provider-that-I-can-come-up-with.aspx kills it.

This has to be in the rewrite module.

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 9/13/2007 7:53:14 AM
Event time (UTC): 9/13/2007 12:53:14 PM
Event ID: 4a383529c60a4221b8ee703f401af83b
Event sequence: 155
Event occurrence: 45
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/442671097/Root-1-128341607080312500
Trust level: High
Application Virtual Path: /
Application Path: D:\HostingSpaces\Blogs\Roman20070807\
Machine name: S8

Process information:
Process ID: 3548
Process name: w3wp.exe
Account name: NT AUTHORITY\NETWORK SERVICE

Exception information:
Exception type: HttpException
Exception message: Cannot use a leading .. to exit above the top directory.

Request information:
Request URL: http://www.romanclarkson.us/post.aspx?id=d4e426a6-048f-4940-b1ec-be7f082f0535
Request path: /post.aspx
User host address: 66.249.73.121
User:
Is authenticated: False
Authentication Type:
Thread account name: NT AUTHORITY\NETWORK SERVICE

Thread information:
Thread ID: 10
Thread account name: NT AUTHORITY\NETWORK SERVICE
Is impersonating: False
Stack trace: at System.Web.Util.UrlPath.ReduceVirtualPath(String path)
at System.Web.Util.UrlPath.Reduce(String path)
at System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative)
at System.Web.HttpResponse.ApplyAppPathModifier(String virtualPath)
at System.Web.UI.HtmlControls.HtmlForm.GetActionAttribute()
at System.Web.UI.HtmlControls.HtmlForm.RenderAttributes(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlControl.RenderBeginTag(HtmlTextWriter writer)
at System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Control.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer)
at System.Web.UI.Page.Render(HtmlTextWriter writer)
at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter)
at System.Web.UI.Control.RenderControl(HtmlTextWriter writer)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Custom event details:

For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.


bloggingdeveloper wrote:
I inserted the code snippet, upload the browser files and checked with http://www.seoconsultants.com/tools/headers/. I received the error again.

Sep 13, 2007 at 3:59 PM
You have to test the posts, categories and authors because they are rewritten. default.aspx was always working. Only the rewritten folders generate this problem.
Coordinator
Sep 13, 2007 at 9:50 PM
Try getting the latest code. I made a little change in the web.config that might solve the problem. Try it out and tell me if it did the trick.
Sep 13, 2007 at 10:11 PM
Change to this to your web.config

<forms timeout="129600" name=".AUXBLOGENGINE" protection="All" slidingExpiration="true" loginUrl="~/login.aspx" cookieless="UseCookies" />

Remove the app_browser files

Then run against http://www.seoconsultants.com/tools/headers/
Sep 21, 2007 at 5:23 PM
I have been using blogEngine for about a month and really like it. I had it working in a subdirectory on my hosted server without any problems. However, once I registered a domain name and pointed it to that subdirectory I started getting this error, but only when I click on the blog title, permalink and comments Hyperlinks. I'm not sure if the domain name masking has something to do with it or not. I was wondering if anyone had found a solution for this problem, or if anyone has any ideas on things to try or may be able to point me in some useful direction.

thanks,
leviticus.
Jul 4, 2008 at 11:35 AM
 
I Encountered this problem also. According to this blog post, it seems there is also a bug in the <asp:Image> control that occurs when rewriting a URL.
pietschsoft.com...rewritten.aspx

I solved the issue by referencing each <asp:Image> in my masterpage with a Fully Qualified URL instead of NavigateUrl="~/somepath/image.jpg"

Regards,
Peter.