YAFLogo

DJGray
  • DJGray
  • 88.8% (Honored)
  • YAF Commander Topic Starter
16 years ago
I keep having C# questions, but cannot post there.

I've created an app that does some data analysis, and want to display whether the service is running or idle, such that if a user connects to the web server (on the same machine) with their browser, they will see displayed "The analyzer is running." or "The analyzer is idle."

The analyzer is started with a button in a browser, and stops when the browser is closed.

Can I write a value to the web.config that controls what this label says? If so, where would such a value belong? Is there a better way to do this?

Sponsor
Mek
  • Mek
  • 100% (Exalted)
  • YAF Developer
16 years ago
Due to the fact we've got our hands full with regular support the decision has been taken to lock those forums as well as the fact it attracted a lot of spam.

Why would you want your label to get the text from a config file? If it only has the two states mentioned above it seems a bit overkill when you cuold have


string statusString = "The analyzer is {0}.";
if (status=="running)
myLabel.Text= String.Format(statusString, "running");
else
myLabel.Text = String.Format(statusString, "idle");

But if your dead set on this you could put the values in the AppSettings section of the web.config; This example shows the Connection String but you can modify it suits your purposes:

http://www.odetocode.com/Articles/345.aspx 


UserPostedImage

"It's a case of RTFM.. the only problem being we don't have a manual!"

When I post FP:Mek in a topic, I'm leaving my footprint there so I can track it once I get into coding/supporting. (Yes I stole this off Ederon 🙂 )

DJGray
  • DJGray
  • 88.8% (Honored)
  • YAF Commander Topic Starter
16 years ago
Thanks Mek. It's entirely possible that I'm overthinking this, but it seems to me that the status of the service needs to be logged outside the browser session. If you log in and start the service, and then I connect at the same time, my browser session will not know that you started the service, unless I can find that information outside your browser session. I was considering a registry entry, but that seemed overkill.

I'll ponder this a bit further and see what I come up with.

test2005
16 years ago

Why not use a global.asax variable? That would be application wide, and where this type of settings should live.


.....the man in black fled across the desert..........and the gunslinger followed.....

jshepler
16 years ago
You probably do not want to write a value to the web.config. For one thing, anytime the web.config changes, the web application will restart itself. If the value needs to survive application restarts, then write to your own file or store it in a database; if not, then any application-scoped property will do (ie. the cache or application collections). Note that IIS6 application pools can restart on their own under specific conditions so don't count on your web app to be running uninterrupted.

If your analyzer is not running in the same AppDomain as your web application, then it would be better for you to implement some way of asking the analyzer itself if it's running or not.


not jsheLPer

DJGray
  • DJGray
  • 88.8% (Honored)
  • YAF Commander Topic Starter
16 years ago
Excellent feedback. If you can't tell, I'm still rather new to C#. I have some ideas, based on your feedback, of how I'll pull this off.

Thanks!!

test2005
16 years ago

jshelper has a point, I run several apps which a "system settings" class and DB table. The class has a simple GET/SET option with setting ID number, returning the value of the setting. On a speedy DB server, this runs great. I have noticed some performance issues on high traffic sites, but nothing I can't live with.

Smaller sites, I use the Global.asax file.

You'll have to see what's best for your situation.

:)


.....the man in black fled across the desert..........and the gunslinger followed.....