Solved

Master Pages in sub directories

Posted on 2012-12-21
23
594 Views
Last Modified: 2012-12-24
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?
0
Comment
Question by:us1975mc
  • 12
  • 7
  • 3
  • +1
23 Comments
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
Try
... MasterPageFile="/Master.Master" ...
0
 

Author Comment

by:us1975mc
Comment Utility
Same thing...
Basicially the same error...
0
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
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.
0
 

Author Comment

by:us1975mc
Comment Utility
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...
0
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
Is there a class in Tech.Master called "ITrack_Web.Tech"?
0
 

Author Comment

by:us1975mc
Comment Utility
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.
0
 
LVL 83

Expert Comment

by:CodeCruiser
Comment Utility
Does it work if you put

MasterPageFile="../Master.Master"
0
 

Author Comment

by:us1975mc
Comment Utility
Have tried "../Master.Master", "~/Master.Master", "/../Master.Master", "~/../Master.Master".  

Strange that it works from my local machine but not on the server.
0
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
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.
0
 

Author Comment

by:us1975mc
Comment Utility
Still error.Do I need to place the Tech Master in the root folder?
0
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
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).
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:us1975mc
Comment Utility
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.
0
 
LVL 33

Expert Comment

by:paulmacd
Comment Utility
"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.
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
Comment Utility
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.
0
 

Author Comment

by:us1975mc
Comment Utility
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?
0
 

Author Comment

by:us1975mc
Comment Utility
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.
0
 

Author Comment

by:us1975mc
Comment Utility
paulmacd,

How do I go about creating a shortcut to the Master.Master in each subfolder?
0
 
LVL 16

Assisted Solution

by:Vikram Singh Saini
Vikram Singh Saini earned 250 total points
Comment Utility
Hi,

Please ignore my previous comment as it was based on some sort of my technical knowledge assumptions.

Now I give try for publishing demo web application in sub directory of my website http://www.vss-tech.com/test.

At first, it failed with same message as you experienced. But later on I changed the published Default.aspx page's page directive from:

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="MasterInSubdir.Default" %>

Open in new window


to

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/test/Site.master" AutoEventWireup="true"
    CodeBehind="Default.aspx.cs" Inherits="MasterInSubdir.Default" %>

Open in new window


Notice the MasterPageFile attribute and it started working fine.

So for your case, I would suggest you to change your code in Default.aspx something as:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/rootFolderName/Master.master
    CodeBehind="Default.aspx.vb" Inherits="ITrack_Web._Default1" %>

Open in new window


Change the code path MasterPageFile="~/rootFolderName/Master.master as per your root folder name. I guess it would be MasterPageFile="~/ITrack Web/Master.master.

Let us know your testing result. If you are publishing, and if it's not so much personally, you can share your link for testing.
0
 

Author Comment

by:us1975mc
Comment Utility
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...
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
Comment Utility
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.
0
 

Author Comment

by:us1975mc
Comment Utility
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.
0
 
LVL 33

Accepted Solution

by:
paulmacd earned 250 total points
Comment Utility
Yes!

"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.
"

Does the root of your application not require a Master page?  Make sure you test it before leaving the root without one...
0
 

Author Closing Comment

by:us1975mc
Comment Utility
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
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now