Page cannot find MasterSheet.

Discussion in 'ASP.NET / ASP.NET Core' started by ateam, Aug 25, 2011.

  1. I have a page that calls for a Mastersheet using the code:

    <%@ Page Language="VB" MasterPageFile="~/MasterSheets/MasterWithEmail.master" AutoEventWireup="false" CodeFile="SamplePage.aspx.vb" Inherits="PublicPages_SamplePage" title="Untitled Page" %>


    <%@ MasterType virtualpath="~/MasterSheets/MasterWithEmail.master" %>


    When I upload the page to the root directory, no problem loading this page. However, when I upload the same page in a subdirectory where it belongs, the page won't load, apparently because it can't find the MasterPage.

    The page loads fine either way, root directory or in subdirectory when run on a local host.

    Any advise on this seemingly easy problem that has stumped me would be appreciated.

    thanks....a
     
  2. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Try coding it using the absolute path. Your server path information can be found in the Account Info/Edit section of your Control Panel.
     
  3. No luck. I changed the code line:

    <%@ MasterType virtualpath="~/MasterSheets/MasterWithEmail.master" %>

    to the one on the server path as suggested:

    <%@ MasterType virtualpath="e:\web\myuser\htdocs" %>


    Is this what you suggesting?


    thanks....a
     
  4. I've never seen the need for the MasterType virtualpath code.

    Try commenting it out...
     
  5. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    I honestly have never used the MasterType virtualpath directive, however, I meant when referencing the MasterPageFile itself, try:

    <%@ Page Language="VB" MasterPageFile="e:\web\myuser\htdocs\MasterSheets\MasterWithEmail.master" AutoEventWireup="false" CodeFile="SamplePage.aspx.vb" Inherits="PublicPages_SamplePage" title="Untitled Page" %>

    I suppose you could do the same for the virtualpath:

    <%@ MasterType virtualpath="e:\web\myuser\htdocs\MasterSheets\MasterWithEmail.master" %>
     
  6. I can help with this if needed.
    It's a trick to overcome the problem.
    We, Microsoft Connect test group, have been using that for a few years now to overcome the same problem. I'm using it on my site as a matter of fact.
    I've posted this "trick" many times in these forums.
    All the best,
    Mark
     
  7. The Virtual Path code line was attempted because

    <%@ Page Language="VB" MasterPageFile="~/MasterSheets/MasterWithEmail.master" AutoEventWireup="false" CodeFile="SamplePage.aspx.vb" Inherits="PublicPages_SamplePage" title="Untitled Page" %>

    would not work.

    The Code line:
    <%@ Page Language="VB" MasterPageFile="e:\web\myuser\htdocs\MasterSheets\ MasterWithEmail.master" AutoEventWireup="false" CodeFile="SamplePage.aspx.vb" Inherits="PublicPages_SamplePage" title="Untitled Page" %>

    Creates an error in the development environment....so not much hope there. And even if this would upload and run on the server, it would be sadness since I would have to change my code every time I run the application in the development environment.

    I would really like to know the "trick" Mark/wisemx mentioned.

    thanks...a
     
  8. Here's a good run-down with code samples: http://msdn.microsoft.com/en-us/library/c8y19k6h.aspx
    Notice that it also shows how to do this in a content page initialization stage, which is very handy.

    The original purpose was to generate a strongly typed property "Master", to give you access to the MasterPage file.

    Keep in mind this is for the Content page.
    The first two lines in that Content page would look like this:

    <%@ Page Title="Content" Language="VB" MasterPageFile="~/maindefault.master" %>
    <%@ MasterType VirtualPath="~/maindefault.master" %>
     
  9. Sorry...I'm still not getting it. I read the article, but it appeared to address pulling specific data off a Master to enter into a content page, or using conditional MasterSheets (eg blue or green background).

    It appears that the code suggested is the same as what I tried per the first posting. I retried the suggested/original code with the same result:

    Content page references Masterpage correctly when the content page is on the root directory of the server, but if I move the content page to a subdirectory where it belongs and try to access, it will not load.

    any other suggestions would be greatly appreciated.

    thanks....az
     
  10. Is it possible the /MasterSheets/ folder is an application?
    If it is each of these methods will fail.
     
  11. Hey that was it! Thanks for your patience wisemx. I have read a lot posts by you, and learned a lot from you on other forums--(I think I remember one discussion even about riding motorcycles?)....

    thanks again....
     

Share This Page