Where do I put user changeable parameters now in 2.0? (global.asax)

G

gordonfmoore

Hi,

for some reason? I learnt it was sensible/useful to put any parameters
that I wanted users to be able to change in the global.asax file.

So my code would look like:

//in my page load
protected void Page_Load(object sender, System.EventArgs e)
{
myLabel.Text = (string) Application["PageHeading"];
string mydbfile = (string) Application["MDBDefault"];
string myLinkToUrl = (string) Application["DefaultWebpage"];
}

//in my global.asax file
<script language = "c#" runat="server">

protected void Application_OnStart()
{
Application["PageHeading"] = "Maths Production (2.0)";
Application["DefaultWebpage"] = "http://intranet";
Application["MDBDefault"] = "App_Data/YAS.mdb";
}
</script>

This worked well under .net 1.1 with precompiled aspx.cs files (as a
dll)

However, they've done it to me again and now I have to fix what wasn't
broken under 2.0

If I use the (afterthought) web deployment projects add in, I can
compile my codebehind, but it also compiles my global.asax and so my
customers can't set up the system parameters as they want to.

So how do I now do this? Please. (I'm not really hacked off - honest!
:( )

Regards

Gordon
 
K

Karl Seguin

All these "configuration" values should either be database driven (if they
need to be managed through an interface) or simply in the web.config. This
is likely the best way in both 1.x and 2.x.

You can either simply use the AppSettings section, or write your own
configuration handler and have a little section to yourself:
http://openmymind.net/index.aspx?documentId=5

Karl
 
C

clintonG

Hey Gordon, read these [1],[2] and if I might nitpick shouldn't your
parameters be written using camel case, i.e. pageHeading and so on?

<%= Clinton Gallagher
METROmilwaukee (sm) "A Regional Information Service"
NET csgallagher AT metromilwaukee.com
URL http://metromilwaukee.com/
URL http://clintongallagher.metromilwaukee.com/


[1] http://msdn2.microsoft.com/library/2y3fs9xs(en-us,vs.80).aspx
[2]
http://msdn.microsoft.com/asp.net/c...l=/library/en-us/dnvs05/html/userprofiles.asp



Karl Seguin said:
All these "configuration" values should either be database driven (if they
need to be managed through an interface) or simply in the web.config.
This is likely the best way in both 1.x and 2.x.

You can either simply use the AppSettings section, or write your own
configuration handler and have a little section to yourself:
http://openmymind.net/index.aspx?documentId=5

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!



Hi,

for some reason? I learnt it was sensible/useful to put any parameters
that I wanted users to be able to change in the global.asax file.

So my code would look like:

//in my page load
protected void Page_Load(object sender, System.EventArgs e)
{
myLabel.Text = (string) Application["PageHeading"];
string mydbfile = (string) Application["MDBDefault"];
string myLinkToUrl = (string) Application["DefaultWebpage"];
}

//in my global.asax file
<script language = "c#" runat="server">

protected void Application_OnStart()
{
Application["PageHeading"] = "Maths Production (2.0)";
Application["DefaultWebpage"] = "http://intranet";
Application["MDBDefault"] = "App_Data/YAS.mdb";
}
</script>

This worked well under .net 1.1 with precompiled aspx.cs files (as a
dll)

However, they've done it to me again and now I have to fix what wasn't
broken under 2.0

If I use the (afterthought) web deployment projects add in, I can
compile my codebehind, but it also compiles my global.asax and so my
customers can't set up the system parameters as they want to.

So how do I now do this? Please. (I'm not really hacked off - honest!
:( )

Regards

Gordon
 
G

gordonfmoore

Thanks guys, that helped. I hadn't realised that web.config could be
used for this.

Clinton, you are probably right :)
 

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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top