Is this normal methodology?

T

Tapplication

I do not consider myself a ASP expert by any means so I must ask this
question to see if this is normal or if there is a better way.

I have a web site that I have developed that uses a lot of DB lookups
for Comboboxes and sections, as well as other configs- All in a
database.

Instead of having this done on EVERY page via direct DB lookups.... We
are talking lots of SQL lookups for every page.

What I want to do is have an included page say SiteHeader.ASPX and do
the following

If Not Application("Initialized") then
InitializeMyApplication()


InitializeMyApplication() Will Do all the database Lookups and create
dropdowns dyanmicly and assign it to a string -- say S,

Application("SiteDropDownList5") = S
Application("Initialized") = True


Then just used this dynamically generated HTML on my pages.


Please Select: <%=Application("SiteDropDownList4")%>


Is this normal?
 
D

Dale

What you propse would certainly work, but why not use the built-in caching
capabilities of ASP.Net?

I typically let my data handler manage the caching. When a method requests,
let's say dsAccountingCodes, for populating a dropdown list, the data handler
checks the cache for a value such as Cache["AccountingCodes"]. If
Cache["AccountingCodes"] is null then the data handler goes to the database,
retrieves the accounting codes list and returns the retrieved list after
storing it for the next request in cache using Cache.Insert.

I usually expire my cached objects in 15 to 30 minutes depending on the
application. You can use timed or other cache dependencies outlined on MSDN.

The next request for the same data will come from cache with no call to the
database.

Here's a place to start:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconCacheAPIs.asp
 
B

Bob Barrows [MVP]

I do not consider myself a ASP expert by any means so I must ask this
question to see if this is normal or if there is a better way.

I have a web site that I have developed that uses a lot of DB lookups
for Comboboxes and sections, as well as other configs- All in a
database.

Instead of having this done on EVERY page via direct DB lookups.... We
are talking lots of SQL lookups for every page.

What I want to do is have an included page say SiteHeader.ASPX and do
the following

If Not Application("Initialized") then
InitializeMyApplication()


InitializeMyApplication() Will Do all the database Lookups and create
dropdowns dyanmicly and assign it to a string -- say S,

Application("SiteDropDownList5") = S
Application("Initialized") = True


Then just used this dynamically generated HTML on my pages.


Please Select: <%=Application("SiteDropDownList4")%>

I was about to suggest using the Cache, but Dale beat me to it. So, instead
i'll leave you with this boilerplate:

There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-knowledgeable person here who
can answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-knowledgeable people hang out. I
suggest microsoft.public.dotnet.framework.aspnet.
 

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,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top