Anyone have experience w/ Application["AppState"]?

J

Julie

I stumbled across Application["AppState"] from someone else's code, and I can't
find out squat about by searching MS, Google, or Google Groups.

For the most part, this is returning the fully-qualified name of the server and
path to my application, such as:

http://devserver/testapp

However, on 1 of my test servers, it returns:

http://localhost/testapp

When browsing the app on the server, that isn't a problem, however if remotely
accessing it from another machine, it is still returning localhost. As
mentioned, the same application on 3 other servers behaves as expected where
the servername is appropriately substituted.

The only difference between the servers is the ones that work are running IIS 5
(XP), the one that doesn't is running IIS 4 (2k). Is there some difference
between these IIS versions that would somehow affect how Application["AppPath"]
is initialized?

Thanks
 
P

Patrice

This is an application variable that is initialized and stored for later
reuse. If you start browsing from localhost, it will record this path and it
will then be incorrect for other users browsing from outside.
Try first to see if it's ok when the application is first accessed when not
using localhost...

It is likely initialized in the global.asax file.
 
J

Julie

Patrice said:
This is an application variable that is initialized and stored for later
reuse. If you start browsing from localhost, it will record this path and it
will then be incorrect for other users browsing from outside.
Try first to see if it's ok when the application is first accessed when not
using localhost...

It is likely initialized in the global.asax file.

Ok, I'm making some progress. What I thought was a predefined value for
AppPath, turns out to be initialized elsewhere in the project (I had searched
the project for occurrences, but nothing showed up for this particular file).

Regardless, I've found the location of the problem, now I need to find a
solution (for the different versions of IIS?).

Thanks


Julie said:
I stumbled across Application["AppState"] from someone else's code, and I can't
find out squat about by searching MS, Google, or Google Groups.

For the most part, this is returning the fully-qualified name of the server and
path to my application, such as:

http://devserver/testapp

However, on 1 of my test servers, it returns:

http://localhost/testapp

When browsing the app on the server, that isn't a problem, however if remotely
accessing it from another machine, it is still returning localhost. As
mentioned, the same application on 3 other servers behaves as expected where
the servername is appropriately substituted.

The only difference between the servers is the ones that work are running IIS 5
(XP), the one that doesn't is running IIS 4 (2k). Is there some difference
between these IIS versions that would somehow affect how Application["AppPath"]
is initialized?

Thanks
 
P

Patrice

The quicker fix I see would be to change every occurence of
Application["AppPath"] with the corresponding expression used for
initializing this variable (would avoid to have a unique value regardless of
the way the website is accessed).

From a general point of view, you may or may not need the full information.
Generally Request.ApplicationPath ( that returns the root of your
application such as "/testapp") should be enough (assuming you want to keep
the same hostname and the same protocol).

Patrice

Julie said:
Patrice said:
This is an application variable that is initialized and stored for later
reuse. If you start browsing from localhost, it will record this path and it
will then be incorrect for other users browsing from outside.
Try first to see if it's ok when the application is first accessed when not
using localhost...

It is likely initialized in the global.asax file.

Ok, I'm making some progress. What I thought was a predefined value for
AppPath, turns out to be initialized elsewhere in the project (I had searched
the project for occurrences, but nothing showed up for this particular file).

Regardless, I've found the location of the problem, now I need to find a
solution (for the different versions of IIS?).

Thanks


Julie said:
I stumbled across Application["AppState"] from someone else's code,
and I
can't
find out squat about by searching MS, Google, or Google Groups.

For the most part, this is returning the fully-qualified name of the server and
path to my application, such as:

http://devserver/testapp

However, on 1 of my test servers, it returns:

http://localhost/testapp

When browsing the app on the server, that isn't a problem, however if remotely
accessing it from another machine, it is still returning localhost. As
mentioned, the same application on 3 other servers behaves as expected where
the servername is appropriately substituted.

The only difference between the servers is the ones that work are
running
IIS 5
(XP), the one that doesn't is running IIS 4 (2k). Is there some difference
between these IIS versions that would somehow affect how Application["AppPath"]
is initialized?

Thanks
 
J

Julie

Patrice said:
The quicker fix I see would be to change every occurence of
Application["AppPath"] with the corresponding expression used for
initializing this variable (would avoid to have a unique value regardless of
the way the website is accessed).

From a general point of view, you may or may not need the full information.
Generally Request.ApplicationPath ( that returns the root of your
application such as "/testapp") should be enough (assuming you want to keep
the same hostname and the same protocol).

Yes, good comments. The original intention by the original author (which I'm
not) was to provide a way in the ASPX pages to properly define paths (to images
in this case) regardless of where the page is located in the site hierarchy,
and regardless of where the site was originally installed in the web server
hierarchy.

The entire qualified name is _not_ needed, so I may be better off using the
Request.ApplicationPath as you point out.

Thanks again for your comments and suggestions.

Julie said:
Patrice said:
This is an application variable that is initialized and stored for later
reuse. If you start browsing from localhost, it will record this path and it
will then be incorrect for other users browsing from outside.
Try first to see if it's ok when the application is first accessed when not
using localhost...

It is likely initialized in the global.asax file.

Ok, I'm making some progress. What I thought was a predefined value for
AppPath, turns out to be initialized elsewhere in the project (I had searched
the project for occurrences, but nothing showed up for this particular file).

Regardless, I've found the location of the problem, now I need to find a
solution (for the different versions of IIS?).

Thanks


"Julie" <[email protected]> a écrit dans le message de
I stumbled across Application["AppState"] from someone else's code, and I
can't
find out squat about by searching MS, Google, or Google Groups.

For the most part, this is returning the fully-qualified name of the
server and
path to my application, such as:

http://devserver/testapp

However, on 1 of my test servers, it returns:

http://localhost/testapp

When browsing the app on the server, that isn't a problem, however if
remotely
accessing it from another machine, it is still returning localhost. As
mentioned, the same application on 3 other servers behaves as expected
where
the servername is appropriately substituted.

The only difference between the servers is the ones that work are running
IIS 5
(XP), the one that doesn't is running IIS 4 (2k). Is there some
difference
between these IIS versions that would somehow affect how
Application["AppPath"]
is initialized?

Thanks
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top