This project is read-only.

Running BlogEngine in Subdirectory

Topics: ASP.NET 2.0
Jan 22, 2010 at 7:00 AM


I'm running BlogEngine in a subdirectory of my main site.

Everything appears to run but when I click on a blog title, the link is broken with the error "Cannot use a leading .. to exit above the top directory."

I am using an older version of BlogEngine but assume this is related to my site configuration but I can't see what is happening. The blog is at Click on the blog title and the error is displayed.

Thanks for any tips!


Jan 22, 2010 at 11:27 AM
Edited Jan 22, 2010 at 11:31 AM

Hi Jonathan, I don't know what the problem is or the solution but the first place I'd look in this instance is in the UrlRewrite.cs class which is located in the core project /Web/HttpModules folder, in 1.5, I don't know if it's the same in earlier versions but you can check in your web config for something similar to

   <add name="UrlRewrite" type="BlogEngine.Core.Web.HttpModules.UrlRewrite, BlogEngine.Core"/>





Jan 22, 2010 at 10:27 PM

I think the problem is with one of the files in your theme folder.

If I try viewing one of the blog posts on your site with the Standard theme by adding the query string parameter "?theme=standard" to the end of the URL there is no error.

It looks like you're using the Coffee House theme.  I haven't used this one.  Do you have a link to where you downloaded it from?  Not sure if you've modified it ... but if I or someone else can look at the code for that theme, we'll probably find the problem.  There's only about 4 files in the theme folder, so it shouldn't be too hard to find the problem.

Jan 23, 2010 at 4:14 AM

Now I'm really baffled. If I try the link you provided (, it shows the topic "Create an RSS Feed in ASP.NET". But if I click the topic, I get the exact same error. You're saying you don't?

At any rate, I got the Coffee House theme from I did customize it but don't believe I did anything related to forming the URLs.


Jan 23, 2010 at 6:59 AM

I'll take a look at the theme.

When you add "?theme=standard", it doesn't persist -- it's only good for that one page view.  If you then click the topic (like you're doing), then a new page is loaded and the regular theme (Coffee House) is used.  So that does make sense.

Jan 23, 2010 at 7:13 AM

I downloaded the theme and tried running it with BE 1.4.5 (the version you're running), but unfortunately didn't get the error.

The person who created the theme is also running BE 1.4.5.  The Coffee House theme appears to work on his site too:

So either a modification you made to the theme caused the problem or there is some other issue with your site.

Of the Standard, Indigo, Mobile and Coffee House themes on your blog, only the Coffee House theme is having this error.  You can test it out with these links:

I would make a backup of your Coffee House theme, and then re-deploy the original Coffee House theme without any modifications to see if it works.

Jan 24, 2010 at 1:56 AM

Many sincere thanks for taking time to look at this.

Taking your advice, I reverted to the original theme and, yes, it appears to work just fine.

I had thought that all my modifications were only cosmetic, but perhaps I broke something. Unfortunately, this issue has been hard for me to try and resolve because I really don't understand how the path stuff works.

On the plus side, I see this is now failing on my development machine so I should be able to step through the code once I figure out what code to step through.

Thanks again!

Jan 24, 2010 at 2:52 AM

I managed to isolate the problem, although I still don't understand it.

First of all, when the error occurs in the debugger, it highlights the closing curly brace at the end of the following code (in themes/CoffeeHouse/site.master):

<uc1:menu ID="Menu1" runat="server" />
<%} %>

<% if (Page.User.Identity.IsAuthenticated) { %>

<div class="adminpath">


<uc1:menu ID="Menu1" runat="server" />


<%} %>

That wasn't much help. But here's my code in the Page_Load event (themes/CoffeeHouse/site.master.cs):
  protected void Page_Load(object sender, EventArgs e)
 RssIconImage1.ImageUrl = "~/themes/" + BlogSettings.Instance.Theme + "/img/rss_24x24.png";
 lnkCodeProject.ImageUrl = "~/themes/" + BlogSettings.Instance.Theme + "/img/codeproject.png";
The first line is in the original theme, I added the second line. If I comment out the second line (the one I added), the error does not occur.
This code is used to set the image URL to an image in the theme subfolder. Since it does exactly what the previous line does, it seems like it should be correct.
Can anyone offer a couple of tips here?
Jan 24, 2010 at 4:17 AM


I was able to resolve this issue by changing the line I added (see previous post) to:


lnkCodeProject.ImageUrl = ResolveUrl("~/themes/" + BlogSettings.Instance.Theme + "/img/codeproject.png");

lnkCodeProject.ImageUrl = ResolveUrl("~/themes/" + BlogSettings.Instance.Theme + "/img/codeproject.png");

I was under the impression that controls like HyperLink with runat="server" would resolve URLs correctly, so I'm not sure why my original line didn't work. But I'm making this change and moving on.

Thanks again for the help, especially BenAmada!