Avatar of us1975mc
us1975mc
Flag for United States of America asked on

Master Pages in sub directories

I have a program that uses a Master Page on the main level and also the same Master page is used on sub levels.  Hopefully a picture is worth a thousand words.
This is the directory structure If I run the program locally (on my machine) it works fine, but if I publish it to the test site it receives errors. Again a picture is worth a thousand words.

This is what the page looks like.The Error File
Any Ideas?
.NET ProgrammingASP.NETVisual Basic.NET

Avatar of undefined
Last Comment
us1975mc

8/22/2022 - Mon
Paul MacDonald

Try
... MasterPageFile="/Master.Master" ...
us1975mc

ASKER
Same thing...
Basicially the same error...
Paul MacDonald

Oh, maps to another application.  The subdirectory has it's own web.config, etc.  

You'll need to copy the Master.Master file to the subfolder, I'm sure.  You might get away with creating a shortcut there, but the reference will have to be within the application.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
us1975mc

ASKER
Still no go...
I placed a Master Page named Tech.Master in the Tech Folder.  I also set MasterPageFile="Tech.Master" in the Default page in the tech folder.  and I get this eror...
Paul MacDonald

Is there a class in Tech.Master called "ITrack_Web.Tech"?
us1975mc

ASKER
This is in the Tech>Master:
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Tech.Master.vb" Inherits="ITrack_Web.Tech" %>

Open in new window


And this is in the Tech.Master.vb:
Public Class Tech

Open in new window


The Project name is ITrack_Web.  

Not really how to get the ITrack_Web into the Public Class Tech.  When I place the ITrack_Web.Tech the Tech gets the squiggly blue line.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Nasir Razzaq

Does it work if you put

MasterPageFile="../Master.Master"
us1975mc

ASKER
Have tried "../Master.Master", "~/Master.Master", "/../Master.Master", "~/../Master.Master".  

Strange that it works from my local machine but not on the server.
Paul MacDonald

Change Tech.Master so it starts with...
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Tech.Master.vb" Inherits="Tech" %>

Note that if you have anothe rpage (something.vb) with the class "Tech" you'll throw another error.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
us1975mc

ASKER
Still error.Do I need to place the Tech Master in the root folder?
Paul MacDonald

Okay, one more time.

In Tech.Master:
<%@ Master Language="VB" AutoEventWireup="false" CodeBehind="Tech.Master.vb" Inherits="Tech_Master" %>

In Tech.Master.vb:
Partial Class Tech_Master

Both files should be in your Admin folder (at least that's the folder we were working in initially).
us1975mc

ASKER
Error #4This is the directory setup.Enclosed is a diagram of what I am working with.  I still get an error with changing to Tech_Master.

In the directory setup I left out that I have a Webconfig in each of the directories Admin, Tech, and User.  I really was wanting to use the Master.Master page that is in the root directory on all of the pages in the Project.  

I guess the question is can I use a master page that is in the root level when in the sub directories I have a full program that has its own webconfig, but is also using the root level webconfig?

Thanks everyone.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Paul MacDonald

"I still get an error with changing to Tech_Master."
The screenshot shows Inherits="Tech"

In any case, I had originally suggested just copying the Master.Master into each subfolder.

Alternately, you can try creating a shortcut to the Master.Master in each subfolder.
Vikram Singh Saini

Hi us1975mc,

After reading the entire discussion between experts and you, I tried developing web application and test it on my development server.

First of all let me share with you my findings.

1. Developed Web Application named as MasterInSubdir with Default.aspx and MasterPage.master in root folder. In Admin folder, there is file Default.aspx page with MasterPageFile set to master file (in root).

2. Then I hosted it directly in virtual directory test on IIS 5.1 . In browser I entered http://localhost/test. I expected it to show me Default.aspx page simply. But the output was asp.net yellow error page. The error was something as:

Server Error in '/test' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Could not load type 'MasterInSubdir.SiteMaster'.

Source Error: 

Line 1:  <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="MasterInSubdir.SiteMaster" %>
Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Source File: /test/Site.master    Line: 1 

Open in new window


Question: Why? So in search of solution I tried deleting temporary files, rechecked code and tested again. No! It didn't worked.

3. Then? Keeping try for solution, I build the entire web application from VS 2010 only. It generated MasterInSubdir.dll in bin folder within root folder (i.e. MasterInSubdir).

Now I tested the http://localhost/test and http://localhost/test/Admin/Default.aspx. Wow! This time both run fine as expected.

As second round of testing, I deleted that generated .dll file from bin folder and tested web app. Fantastic! It showed me the same type of error message again.

CONCLUSION:
You are facing error because of either of following reasons:

1. You done some changes in web application and then published the web application without building it locally. I'm just trying to explain (as you know I'm not so much hosting expert). So the .dll files not updated.

2. Or you published web application from scratch, but not build the web application from VS 2010.

So my suggestion: Remove or delete the entire hosted files (if possible). Build your web application from VS IDE. Confirm if the .dll file named per your web application is showing in bin folder. Then publish your web application on test site. Test it. I believe it should work now as all stuff is available for making it to run.
us1975mc

ASKER
vs00saini WOW!

I just read through your comments and have that I will need to read through it several more times.  I appreciate the time and effort that you have placed in my question.

Question:  When you state "You done some changes in web application and then published the web application without building it locally", I am not sure what you mean by locally. What I usually do (not to say that this is correct) but periodically I try posting the code to the Test site. In doing this I go to Build and Press Publish web-App.  Is there a step that I am missing?
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
us1975mc

ASKER
Maybe I didn’t really clarify myself.  I have this program with Master.Master in the root and also a Default.aspx in the root.  Then I have three sub directories, that each are working programs, and they each have a Default.aspx page in them that uses the Master.Master in the root directory.  On my locao machine the program works flawlessly.  It is only when I publish the program that I start getting errors.  

I can see the master page and all pages in the root directory when I publish.  It is only the programs in the sub directories that error out.
us1975mc

ASKER
paulmacd,

How do I go about creating a shortcut to the Master.Master in each subfolder?
SOLUTION
Vikram Singh Saini

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
us1975mc

ASKER
vs00saini,

I wished that I could let you look at the code but I am not able to do that for business reasons. ( Bah Humbug)

I do appreciate the help that everyone has been giving.  Thanks and I am still working on this...
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Vikram Singh Saini

Hi,

That's no issue. We all are restricted to share something due to different reasons. And it's not necessary to share. I just asked for helping you. Please ignore that part.

However I would like to know your testing result as I asked for.
us1975mc

ASKER
I believe that I have found the problem.  I have the 3 subfolders set up as a seperate application. When I place a Master page in each of the folders and get rid of the main level they seem to work properly.  So I am currently working on changing the Master pages around to see if that work for all of the pages.
ASKER CERTIFIED SOLUTION
Paul MacDonald

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
us1975mc

ASKER
I should have known, but it worked on my machine locally.  Placing in each application will do the job.  

Have learned a lot from both of you on this question.  Everything that I know is from being self taught and Experts Exchange has been a great help when all seams lost.  

Thanks to all for the help!

Semper Fidelis,

us1975mc
Your help has saved me hundreds of hours of internet surfing.
fblack61