Issue with Pages in BlogEngine.Net not rendering correctly

Dec 31, 2009 at 8:18 PM

Hi,

   I've been using blogengine.net for ages for my own blog, but I'm provisioning a new site for my usergroup and have set up blogengine.net for it (http://www.nebytes.net) my problem is occurring with pages.  I have set up an about page and an events page.  I can see the correct rendering in the site admin pages editor and in Windows Live Writer however when I view the page in a browser all I see is random ASCII characters.  I'm not seeing this on my development machine but see it all the time in my hosting environment.  Has anyone experienced this before?  The problem pages are http://www.nebytes.net/page/about.aspx and http://www.nebytes.net/page/events.aspx I'm on W2K8 with IIS7 integrated mode and I've migrated the web.config

I'm racking my brains on this one

Andrew

Coordinator
Dec 31, 2009 at 9:53 PM

Just a quick thought ... in the web.config file, are you setting a value for the BlogEngine.VirtualPath setting:

<add key="BlogEngine.VirtualPath" value="~/"/>

That value above is the default.  I'm wondering if you have something like ../

Dec 31, 2009 at 9:56 PM

Got a little bit further with this one thanks to the following post - http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=72854 and adding the code to the global.asax file as described in the referred post - http://blogengine.codeplex.com/Thread/View.aspx?ThreadId=51114

Now when I browse to one of the pages I get the following error:  System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Web.HttpException: Cannot use a leading .. to exit above the top directory. 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.UI.Control.ResolveClientUrl(String relativeUrl) at System.Web.UI.WebControls.Image.AddAttributesToRender(HtmlTextWriter writer) at System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) at System.Web.UI.WebControls.WebControl.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.WebControls.HyperLink.RenderContents(HtmlTextWriter writer) at System.Web.UI.WebControls.WebControl.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.Control.Render(HtmlTextWriter writer) at WidgetBase.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.Control.Render(HtmlTextWriter writer) at Controls.WidgetZone.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 ASP.themes_nebytes_site_master.__RenderForm1(HtmlTextWriter __w, Control parameterContainer) at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) at System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) at System.Web.UI.HtmlControls.HtmlContainerControl.Render(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 BlogEngine.Core.Web.Controls.BlogBasePage.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) --- End of inner exception stack trace --- at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.page_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I've replicated my hosting environment at home i.e. installed blogengine.net to the root folder, not in a sub folder, and can reproduce the error.  Therefore I assume it's an issue with setting up a site with blogengine.net at the root.  How can I get round this issue?  Surely there are many others hosting the application in the same way I am?

Andrew

Dec 31, 2009 at 10:07 PM

I haven't made any changes to the appSettings and I've just checked the web.config file and this is what I have set 

<font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

<

</font></font></font><font face="Consolas" size="2" color="#0000ff"><font face="Consolas" size="2" color="#0000ff">

 

</font></font><font face="Consolas" size="2" color="#0000ff">

 

</font>

add key="BlogEngine.VirtualPath" value="~/" />

any ideas?

Coordinator
Dec 31, 2009 at 10:36 PM

It was just an idea.  The error that is occurring is:

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

Are you using some form of URL rewriting for this website?  I think BE (ASP.NET) thinks your website is located in a sub-folder, and it's trying to get back to the parent folder which is outside the top directory of the BE application.

I've ran into something like this before.  Probably in order for the application to run in this situation, some modifications are needed to the code so it realizes that it shouldn't try and go back more folders than it can.  Offhand, I'm not sure the extent of changes needed to get the application working again in this scenario.

Is the only thing not working the Pages?  Are Posts working, and everything else too?

Dec 31, 2009 at 10:47 PM

Hi,

    the url rewriting module is installed on the host and in my development environment on the server but it is not being used.  I haven't done much customisation apart from modified a theme and added some html to the twitter widget.ascx file.

Apart from that it's a standard install.  I wasn't expecting to have these errors.  I run my own blog in a subdirectory - http://www.andrewwestgarth.co.uk/blog however for the NEBytes group site I didn't want to do that.

Nope I'm afraid the posts aren't working either.  I can view the archive, contact, rss feed and administration sections fine tho :S

Thanks for your time on this.

Coordinator
Dec 31, 2009 at 11:01 PM

Maybe try removing the widgets to see if it makes any difference.  It looks like the error may be occurring while a widget is being rendered (maybe the Twitter widget?).  But that could just be a coincidence, and once the widgets are removed, the same error might occur somewhere else along the line.

Also, if you're using any custom BE Extensions, I would try disabling those to see if it makes any difference.

Dec 31, 2009 at 11:21 PM

Hi Thanks for the tip.  I've worked my way through the list of widgets I have running on the site.  I've identified the problem to being with the twitter widget.  I've disabled it for now and will take a look at the code in the morning to identify the problem.

Thanks for your help :)

Happy New Year!

Jan 1, 2010 at 5:34 PM

Hi I got back to work on this today and narrowed down the issue to a problem with a modification I'd made to the hyperlink control in the twitter widget.ascx  I'd added the ImageUrl property to add an image to the hyperlink rather than just have the text link.  I added the following: ImageUrl="~/pics/twitter.jpg" and this was what was causing the error.  I changed this to ImageUrl="<%=BlogEngine.Core.Utils.RelativeWebRoot %>pics/twitter.jpg" but this too broke.  For the purposes of our site I have managed to get the widget to work by setting the ImageUrl property to ImageUrl="/pics/twitter.jpg" but this only works when the application is installed at the root level of the site.  If the app is installed in a subdirectory say /blog/ then it breaks the image link. 

Ideally I'd like to fix this properly for all installs.  Will keep looking on it when I get a second.

Coordinator
Jan 1, 2010 at 7:08 PM

You probably don't want to mix code block syntax <%= %> when using server controls like <asp:Image>.  The <%= %> code blocks are helpful if you use a standard <img> tag.  I think going with a non-server <img> tag will work and is simplest in this case:

<img src="<%=BlogEngine.Core.Utils.RelativeWebRoot %>pics/twitter.jpg" />