Trouble with Multiple Master Pages in ASP.NET 2.0

G

Guest

I am writing an ASP.NET 2.0 application that uses more than one master page.
Currently, there are two pages, Freedom1.master and Freedom2.master. I have
no problems with Freedom1.master. However, I am having problems with
Freedom2.master.

The first problem is I sometimes get the following error when I build the
site.

The type 'Freedom2' exists in both
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web_ammoxc8r.dll' and
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web_fxnhzrev.dll'

The error appears for each page built using Freedom2.master.

The second problem occurs at runtime for statments like the following.

protected void Page_Load(object sender, EventArgs e)
{

Freedom2 master = (Freedom2)Master;
master.Page.Header.Title = "Freedom LINC Registration";
 
G

Guest

Your code looks a bit confusing, you seem to be declaring an object called
master of type freedom2 and initialising it with the value contained in it's
self cast as a type freedom2. What are trying to do with that code?
 
G

Guest

In this case I am changing the title of the page with the statement,

master.Page.Header.Title = "Freedom LINC Registration";

There are other occasions I wish to access properties on the master page
from the aspx page that uses it. For example to change the href on a link.

My problem is that I have multiple master pages, e.g. Freedom1. All inherit
from the Master class. Freedom1 derived pages work fine but I am getting
intermittent compilation or runtime errors with Freedom2.

Thanks,
EagleRed
 
A

Alan Silver

"(e-mail address removed)"
I am writing an ASP.NET 2.0 application that uses more than one master page.
Currently, there are two pages, Freedom1.master and Freedom2.master. I have
no problems with Freedom1.master. However, I am having problems with
Freedom2.master.

The first problem is I sometimes get the following error when I build the
site.

The type 'Freedom2' exists in both
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web_ammoxc8r.dll' and
'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\freedomlincwebsite\ae6160cc\fecd2ea4\App_Web_fxnhzrev.dll'

The error appears for each page built using Freedom2.master.

Try stopping the server, then deleting the files in the temporary
ASP.NET files folder. Then restart the server and try again. I have seen
this cure this problem.
The second problem occurs at runtime for statments like the following.

protected void Page_Load(object sender, EventArgs e)
{

Freedom2 master = (Freedom2)Master;
master.Page.Header.Title = "Freedom LINC Registration";
<snip>

Why are you doing it this way? Title is a standard property of the page,
even when master pages are used, so you can simply do...

Page.Header.Title = "Freedom LINC Registration";

More to the point, if you are setting the title to a fixed string, just
set it in the Page directive of the .aspx file instead of in code. As I
understand it, this gets compiled with the page, so will be a teensy
weensy bit faster too.

HTH
 
D

DamijanD

Needed or non needed code I have the same problem:

I usually cast master in order to hide or show some components / parts
of page. Anyhow why I want to cast master page is not an issue here.
The issue is why this cast may or may not fail.
My findings are that:
- I assume that in place compilation creates 2 copies of assembly,
- killing w3wp usually helps (if it doesn't delete asp.net tmp
folders/files),
- it may happens only after some compilation was made (after changes in
files, etc...).

I belive that, precompiled deployment is safer regarding this
problem...

I would like some more info about that problem.

bye,
D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top