Re: where to put this code?
From: Lucas Tam (REMOVEnntp_at_rogers.com)
Date: 12/11/04
- Next message: Lucas Tam: "Re: Auto Run ASP.NET pages"
- Previous message: Khurram Hanif: "Auto Run ASP.NET pages"
- In reply to: V. Jenks: "where to put this code?"
- Next in thread: V. Jenks: "Re: where to put this code?"
- Reply: V. Jenks: "Re: where to put this code?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 11 Dec 2004 08:10:49 GMT
"V. Jenks" <anonymous@discussions.microsoft.com> wrote in
news:114001c4df45$f750ed70$a401280a@phx.gbl:
> What I need is a way to safely store the current string and
> the 2 integers in a way that will guarantee I do not lose
> the values, it is important that each time I generate the
> string, it is unique, as it is used as a primary key in my
> database tables.
Not a very safe way of generating PKs... Isn't there anything else you
can use a PK? Or this newly generate PK should be checked as soon as
possible to ensure it's uniquness.
> If I were to load the values from say, an XML file when the
> program loads in Application_Start in the Global.asax
> code-behind, could I safely keep them in memory and are
> they guaranteed to remain in state while the application is
> running? I was thinking I would re-write the values back
> into the XML file in the Application_End event handler.
No, if the application crashes, bye bye values!
> BUT...when exactly is Application_Start fired and when
> exactly is Application_End fired? What constitutes a web
> application starting and ending? Does it end when there
> are no more active sessions in the app?
Applicatin Start is fired when the application is first loaded.
Application End is fired when the application is shut down - I believe
typically 20+ minutes of inactivity. There maybe other situations where
application end is fired.
But generally speaking, you don't want to use Application_End for
process that MUST occur... because application_end has been shown to be
unreliable from time to time.
> Could I safely pull this off w/o any concurrency problems
> when writing/reading to the XML files to get my values?
>
> I would store these values in a database table but I don't
> want to make a new connection and round-trip to the
> database every time I need a value to insert as a primary
> key, this would murder my app's performance.
Perhaps you should look at generating the key in the database?
Or add some error handling logic in your PK generation routines... such
as checking the PK to make sure it's a valid PK before returning back to
the user. It's probably not a good idea just to rely on an XML file or
in memory store... as they could get out of sync with the server or data
could have been lost on a crash.
-- Lucas Tam (REMOVEnntp@rogers.com) Please delete "REMOVE" from the e-mail address when replying. http://members.ebay.com/aboutme/coolspot18/
- Next message: Lucas Tam: "Re: Auto Run ASP.NET pages"
- Previous message: Khurram Hanif: "Auto Run ASP.NET pages"
- In reply to: V. Jenks: "where to put this code?"
- Next in thread: V. Jenks: "Re: where to put this code?"
- Reply: V. Jenks: "Re: where to put this code?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|