ASP.NET Application - Defined???

S

Steve Taylor

I am having trouble understanding the ASP.NET application boundaries. Here's my setup:

1. Win2003 Server with IIS 6 and an application defined at the root "SalesNow" (www.salesnow.com).

2. A Default.aspx at the root which redirects the user to "Pages/Main.aspx" using javascript window.location.

3. On the Pages/Main.aspx page a HyperLink control which I add a javascript onclick event which does the

following:
- NewLeadWin = window.open("NewLeads.aspx", "NewLeadWin", "width=700, height=500, location=no, top=20, left=20, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
- NewLeadWin.window.focus();

Scenarios:
1. When the Default.aspx contains "window.location = '/Salesnow/Pages/Main.aspx'" the NewLeadWin works just fine, yet, the session state is not transferred. Trace must be run in both the root and /pages to get output.

2. When the Default.aspx contains "window.location = '/Pages/Main.aspx'" the NewLeadWin fails giving the familiar error regarding WEB.CONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.

Note: getting to Main.aspx is no problem, but the opening of the NewLeads.aspx is.

Question: I thought everything defined within and below the application folder (wwwroot in this case) was

considered part of the app. Why is this behavior so?
 
K

Kevin Spencer

It sounds like you're mixing up Session and Application state. Both pages
ARE in the same application. However, a single Application can contain many
Sessions, one per client browser.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

I am having trouble understanding the ASP.NET application boundaries.
Here's my setup:

1. Win2003 Server with IIS 6 and an application defined at the root
"SalesNow" (www.salesnow.com).

2. A Default.aspx at the root which redirects the user to "Pages/Main.aspx"
using javascript window.location.

3. On the Pages/Main.aspx page a HyperLink control which I add a javascript
onclick event which does the

following:
- NewLeadWin = window.open("NewLeads.aspx", "NewLeadWin", "width=700,
height=500, location=no, top=20, left=20, menubar=no, status=no, toolbar=no,
scrollbars=yes, resizable=yes");
- NewLeadWin.window.focus();

Scenarios:
1. When the Default.aspx contains "window.location =
'/Salesnow/Pages/Main.aspx'" the NewLeadWin works just fine, yet, the
session state is not transferred. Trace must be run in both the root and
/pages to get output.

2. When the Default.aspx contains "window.location = '/Pages/Main.aspx'"
the NewLeadWin fails giving the familiar error regarding WEB.CONFIG: It is
an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level.

Note: getting to Main.aspx is no problem, but the opening of the
NewLeads.aspx is.

Question: I thought everything defined within and below the application
folder (wwwroot in this case) was

considered part of the app. Why is this behavior so?
 
E

Eran Kampf

The error you are getting when accessing the Pages folder is because you included a web.config file in that folder that conatins application level definitions (forms authentication settings for example).
Everything defined within and below the application folder (wwwroot in this case) is considered part of the app but definitions such as the ones you put on the web.config in Pages require it to be a seperate ASP.NET application...
To solve the problem you need to define the Pages folder as an application in the IIS properties dialog.

Eran Kampf
http://www.ekampf.com

I am having trouble understanding the ASP.NET application boundaries. Here's my setup:

1. Win2003 Server with IIS 6 and an application defined at the root "SalesNow" (www.salesnow.com).

2. A Default.aspx at the root which redirects the user to "Pages/Main.aspx" using javascript window.location.

3. On the Pages/Main.aspx page a HyperLink control which I add a javascript onclick event which does the

following:
- NewLeadWin = window.open("NewLeads.aspx", "NewLeadWin", "width=700, height=500, location=no, top=20, left=20, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
- NewLeadWin.window.focus();

Scenarios:
1. When the Default.aspx contains "window.location = '/Salesnow/Pages/Main.aspx'" the NewLeadWin works just fine, yet, the session state is not transferred. Trace must be run in both the root and /pages to get output.

2. When the Default.aspx contains "window.location = '/Pages/Main.aspx'" the NewLeadWin fails giving the familiar error regarding WEB.CONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.

Note: getting to Main.aspx is no problem, but the opening of the NewLeads.aspx is.

Question: I thought everything defined within and below the application folder (wwwroot in this case) was

considered part of the app. Why is this behavior so?
 
S

Steve Taylor

I wish it were that easy! As you can see, I am having trouble just
describing this strange behavior. What started me on this track was wanting
to initialize my session business object at the Defaut.aspx (one-time
gateway to the app). Here's how it works today:
- A user is linked to the Default.aspx from our intranet (classic asp) app
via a hyperlink (using window.open).
- The Global.asax Session_Start creates and stores the user's skeleton
business object into session state (ServerState).
- Then the Default.aspx simply validates where they were coming from (has to
be the intranet url) and transferrs them & their ID to pages/main.aspx.
- Then Main.aspx did the bus obj user validation and filled out the rest of
the object values.

This is all working nicely today, but I want to move the user validation
back to Default.aspx and then update the stored object in session, then
transfer them to Main.aspx. In each form, I instantiate the bus object (on
init) and do the work. The great thing about this is that I can detect when
their session times out (based on null values) on each Form Load event and
handle differently from other errors.

Simply moving the bus obj validation routine back into Default.aspx causes
the object to be missing those values upon getting to the Main.aspx page????
Sure the Default.aspx is in the apps root and Main.aspx is in a sub-folder
(pages), but why would that cause an issue with session state?

Steve
 
S

Steve Taylor

No, there is no other web.config file. Just the one at the root.
The error you are getting when accessing the Pages folder is because you included a web.config file in that folder that conatins application level definitions (forms authentication settings for example).
Everything defined within and below the application folder (wwwroot in this case) is considered part of the app but definitions such as the ones you put on the web.config in Pages require it to be a seperate ASP.NET application...
To solve the problem you need to define the Pages folder as an application in the IIS properties dialog.

Eran Kampf
http://www.ekampf.com

I am having trouble understanding the ASP.NET application boundaries. Here's my setup:

1. Win2003 Server with IIS 6 and an application defined at the root "SalesNow" (www.salesnow.com).

2. A Default.aspx at the root which redirects the user to "Pages/Main.aspx" using javascript window.location.

3. On the Pages/Main.aspx page a HyperLink control which I add a javascript onclick event which does the

following:
- NewLeadWin = window.open("NewLeads.aspx", "NewLeadWin", "width=700, height=500, location=no, top=20, left=20, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=yes");
- NewLeadWin.window.focus();

Scenarios:
1. When the Default.aspx contains "window.location = '/Salesnow/Pages/Main.aspx'" the NewLeadWin works just fine, yet, the session state is not transferred. Trace must be run in both the root and /pages to get output.

2. When the Default.aspx contains "window.location = '/Pages/Main.aspx'" the NewLeadWin fails giving the familiar error regarding WEB.CONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level.

Note: getting to Main.aspx is no problem, but the opening of the NewLeads.aspx is.

Question: I thought everything defined within and below the application folder (wwwroot in this case) was

considered part of the app. Why is this behavior so?
 
K

Ken Dopierala Jr.

Hi Steve,

Are these multiple apps? In your /Pages folder do you have a Bin directory?
Ken.
 
K

Kevin Spencer

Hi Steve,

I'm somewhat confused, but I'll take a crack at helping as much as I can.

A web application is defined as a virtual root directory (a directory which
is configured in IIS as an Application), and all of the directories
underneath it which are NOT defined as applications. It sounds like your IIS
Application configuration is messed up. I would start by taking a look at
that.

Opening a browser window using JavaScript may or may not initiate a new
Session, depending upon the browser. I wouldn't count on it.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
S

Steve Taylor

Thanks Ken.

No - not multiple apps. I have set up a web server and set its home
directory as w:\wwwroot\salesnow and configured the application name =
"Salesnow". That same directory is set up as a virtual directory with
identical values. Is that the problem, maybe I don't need the virtual
directory since the web server is dedicated to this site?

FYI: as a test, I set up a Win2K Web server identically (except that it
truely is a virtual web site) and it reacts as designed.

Let me know.
Thanks.
 
S

Steve Taylor

Thanks Kevin,
I agree something is wrong and I'm really suspecting it is on the server
config. Please see my response to Ken for more details. Any ideas will be
much appreciated.
Steve
 
K

Kevin Spencer

You say you "set up a web server and set its home directory as..." Then you
say "That same directory is set up as a virtual directory with identical
values." It sounds like you've got 2 applications pointing to the same
directory. The web server is IIS. I believe you mean you set up a web SITE.
Basically, you've set up 2 virtual directories and applications pointing to
the same directory. Remove the virtual directory you added, and it should be
fine.

The term "virtual directory" can be confusing. A virtual directory is
basically any directory that you map to in IIS. It can be under the default
(C:\Inetpub\wwwroot) web server directory, or it can reside elsewhere, and
be mapped as a virtual directory in IIS. So, in essence, you've created 2
virtual directories from one directory, and created 2 applications that
point to the same directory structure.

.... if I'm understanding you correctly.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
S

Steve Taylor

You are absolutely right! That was the problem and thinking about how it
reacted makes sense in this context.

THANKS FOR ALL YOU DO!
 

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top