none
Getting error referencing master page at the root from a file in a subfolder. RRS feed

  • Question

  • I created a master page 1.master at the root folder of my website.  Then I created a default.aspx page in a subfolder called testfolder.  I'm getting an error with the default.aspx page when I add the master page 1.master. 

    I've tried <%@ Page Language="C#" masterpagefile="../1.master" title="Untitled 1" %>  OR  <%@ Page Language="C#" masterpagefile="~/1.master" title="Untitled 1" %> and I get the same error message.  What am I doing wrong?

    Stack Trace: 

    [HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]
       System.Web.Util.UrlPath.ReduceVirtualPath(String path) +8908022
       System.Web.Util.UrlPath.Reduce(String path) +52
       System.Web.Util.UrlPath.Combine(String appPath, String basepath, String relative) +217
       System.Web.UI.Control.ResolveClientUrl(String relativeUrl) +258
       System.Web.UI.HtmlControls.HtmlLink.RenderAttributes(HtmlTextWriter writer) +74
       System.Web.UI.HtmlControls.HtmlLink.Render(HtmlTextWriter writer) +42
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) +21
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       System.Web.UI.Control.Render(HtmlTextWriter writer) +10
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8
       System.Web.UI.Page.Render(HtmlTextWriter writer) +29
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3060

    Roger Muscarello

    Tuesday, April 24, 2012 3:33 AM

Answers

  • Thanks for your response.  It wasn't the way I was referencing the master page in the default.aspx.  The problem was the way I was referencing the hyperlinks, images, and css in the master page.  I had to change the hyperlinks, and images to asp controls instead of html controls so I could use the ~/ to reference the item.  Once I made those changes I could reference the master page from any level of subdirectory.

    Roger Muscarello

    • Marked as answer by rmuscarello Wednesday, April 25, 2012 4:14 AM
    Wednesday, April 25, 2012 4:13 AM

All replies

  • Are you editing by opening the site first?  And EW's version of the site directory is where the root folder is?

    "Cannot use a leading .. to exit above the top directory" - says something in the page is trying to go above your root directory.

    You would get this error if, for example, you turned your subdirectory into a subsite.  As far as EW is concerned, that means the subdirectory is the root of the site when you are editing files inside it.


    • Edited by KathyW2 Tuesday, April 24, 2012 1:18 PM
    Tuesday, April 24, 2012 5:37 AM
  • Thanks for your response.  It wasn't the way I was referencing the master page in the default.aspx.  The problem was the way I was referencing the hyperlinks, images, and css in the master page.  I had to change the hyperlinks, and images to asp controls instead of html controls so I could use the ~/ to reference the item.  Once I made those changes I could reference the master page from any level of subdirectory.

    Roger Muscarello

    • Marked as answer by rmuscarello Wednesday, April 25, 2012 4:14 AM
    Wednesday, April 25, 2012 4:13 AM