Suggestions please for strategy to share values across app.
Scenario:
I have an asp.net app that uses some com components along with .net classes.
Configuration settings for various things are held in an xml file to which
the com has access. The xml file has different nodes for different instances
(dev,uat1,uat2 etc..) there is a flag attribute to show current instance.
The asp.net app loads the xml in global.asax and extracts a bunch of data
into Application.item variables.
What I can't then do is access the Application variables from any classes in
the app that are not associated with a web page.
Yes I can put the values into web.config but this present 2 problems
- you need to write a messy section handler with namevalue object to read
any data
- the com can't see the file (well it can but for admin purposes you
shouldn't need to duplicate values - more scope for going wrong)
Can anyone think of a way in which I can pass Application variables back to
a class?
Thanks 5 1885
Hi Adolf:
As long as the class is working during a web request, it can use
System.Web.HttpContext.Current to tap into the context of the web
request. For example:
HttpContext.Current.Application["foo"] = o;
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 11 Nov 2004 04:29:06 -0800, adolf garlic
<ad*********@discussions.microsoft.com> wrote: Suggestions please for strategy to share values across app.
Scenario:
I have an asp.net app that uses some com components along with .net classes.
Configuration settings for various things are held in an xml file to which the com has access. The xml file has different nodes for different instances (dev,uat1,uat2 etc..) there is a flag attribute to show current instance.
The asp.net app loads the xml in global.asax and extracts a bunch of data into Application.item variables.
What I can't then do is access the Application variables from any classes in the app that are not associated with a web page.
Yes I can put the values into web.config but this present 2 problems - you need to write a messy section handler with namevalue object to read any data - the com can't see the file (well it can but for admin purposes you shouldn't need to duplicate values - more scope for going wrong)
Can anyone think of a way in which I can pass Application variables back to a class?
Thanks
> Can anyone think of a way in which I can pass Application variables back
to a class?
It's important that you grip them over the laces. Put a good spin on them,
and just heave with all your might. Be sure to follow through. From that
point, it's up to the class to catch them.
;-)
Actually, if I understand you correctly, you want to ACCESS application
variables FROM a class, right? Now, in .Net, everything is a class, so I'm
going to have to go out on a limb and guess that what you are referring to
is classes that are not Page classes. In that case, you can access the
Application as System.Web.HttpContext.Current.Application.
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"adolf garlic" <ad*********@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com... Suggestions please for strategy to share values across app.
Scenario:
I have an asp.net app that uses some com components along with .net
classes. Configuration settings for various things are held in an xml file to which the com has access. The xml file has different nodes for different
instances (dev,uat1,uat2 etc..) there is a flag attribute to show current instance.
The asp.net app loads the xml in global.asax and extracts a bunch of data into Application.item variables.
What I can't then do is access the Application variables from any classes
in the app that are not associated with a web page.
Yes I can put the values into web.config but this present 2 problems - you need to write a messy section handler with namevalue object to read any data - the com can't see the file (well it can but for admin purposes you shouldn't need to duplicate values - more scope for going wrong)
Can anyone think of a way in which I can pass Application variables back
to a class?
Thanks
I just noticed that your message did mention that your prlbme was with
classes that are "not associated with a web page." So, I guessed correctly,
even though I missed that the first time I read your message. In fact, for
future reference, classes that have direct access to the current HttpContext
are any classes which implement IHttpHandler (such as Page) or IHttpModule.
Other classes must refer to the static "Current" member of
System.Web.HttpContext, and of course, they must be used in that context in
order to access it (such as in a web application or Web Service).
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"adolf garlic" <ad*********@discussions.microsoft.com> wrote in message
news:46**********************************@microsof t.com... Suggestions please for strategy to share values across app.
Scenario:
I have an asp.net app that uses some com components along with .net
classes. Configuration settings for various things are held in an xml file to which the com has access. The xml file has different nodes for different
instances (dev,uat1,uat2 etc..) there is a flag attribute to show current instance.
The asp.net app loads the xml in global.asax and extracts a bunch of data into Application.item variables.
What I can't then do is access the Application variables from any classes
in the app that are not associated with a web page.
Yes I can put the values into web.config but this present 2 problems - you need to write a messy section handler with namevalue object to read any data - the com can't see the file (well it can but for admin purposes you shouldn't need to duplicate values - more scope for going wrong)
Can anyone think of a way in which I can pass Application variables back
to a class?
Thanks
Hi,
Just a thought, Can't you pass the application settings as a parameter to
the caller?
As the context is entirely different( I mean the web context and your
processing classes), or in other words ,configuration is different from
processing classes, will you be able to change your code to accept
application settings as parameters from the asp.net page?
--
Arul
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:be********************************@4ax.com... Hi Adolf:
As long as the class is working during a web request, it can use System.Web.HttpContext.Current to tap into the context of the web request. For example:
HttpContext.Current.Application["foo"] = o;
-- Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 11 Nov 2004 04:29:06 -0800, adolf garlic <ad*********@discussions.microsoft.com> wrote:
Suggestions please for strategy to share values across app.
Scenario:
I have an asp.net app that uses some com components along with .net classes.
Configuration settings for various things are held in an xml file to which the com has access. The xml file has different nodes for different instances (dev,uat1,uat2 etc..) there is a flag attribute to show current instance.
The asp.net app loads the xml in global.asax and extracts a bunch of data into Application.item variables.
What I can't then do is access the Application variables from any classes in the app that are not associated with a web page.
Yes I can put the values into web.config but this present 2 problems - you need to write a messy section handler with namevalue object to read any data - the com can't see the file (well it can but for admin purposes you shouldn't need to duplicate values - more scope for going wrong)
Can anyone think of a way in which I can pass Application variables back to a class?
Thanks
Yes, you can always pass those items as parameters. I'd avoid passing
a reference to the entire Application collection as that can be easily
retreived with HttpContext.Current, but if I wanted to decouple my
classes from being used strictly in an asp.net app I'd pass the values
along and avoid HttpContext.Current and referencing
HttpApplicationState. You could always package the parameters into a
Hashtable or pass them individually.
--
Scott http://www.OdeToCode.com/blogs/scott/
On Thu, 11 Nov 2004 08:55:37 -0600, "lezmark" <le*****@cox.net> wrote: Hi, Just a thought, Can't you pass the application settings as a parameter to the caller? As the context is entirely different( I mean the web context and your processing classes), or in other words ,configuration is different from processing classes, will you be able to change your code to accept application settings as parameters from the asp.net page? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Doug Jordan |
last post by:
I am fairly new to Python. This should be an easy answer but I cannot get
this to work. The code is listed below. I know how to do this in C,
Fortran, and VB but it doesn't seem to work the same...
|
by: Brian F |
last post by:
Exactly what the subject says.
I have an ASP page that I want my C# windows application to open in
Internet Explorer, and if possible have it send along a list of values
from a list box. Thank you.
|
by: Melson |
last post by:
Hi
Can anyone help me with this problem. I've a form1(entry form) with datagrid
which bound to a dataset (datagrid.setdatabinding(dataset,"table")). I've a
public class Capturekey in form1 which...
|
by: raylopez99 |
last post by:
Keywords: scope resolution, passing classes between parent and child
forms, parameter constructor method, normal constructor, default
constructor, forward reference, sharing classes between forms....
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |