![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an ASP app that i'm porting over ASP.Net In an asp page i have many server.execute statements. So in the asp page code i have something like this % session("objectid") = 1001778 server.execute("multimedia.aspx") session("objectid") = 1001779 server.execute("multimedia.aspx") session("objectid") = 1001899 server.execute("listrecords.aspx") session("objectid") = 1001778 server.execute("multimedia.aspx") % Now i want only some code on the multimedia.aspx page to be cached as some of the queries on the page are dynamic. However i also want the page caching to vary based upon the objectid number in the session variable. (BTW i am using a method that allows ASP sessions to be shared with ASP.net sessions). what i don't quite understand is that if i set the OUTPUTCACHE at the top of page (in the .aspx file) to be cached and i use user controls in the ASPX page for the dynamic queries is it possible to set the user controls so they are not cached or .... can you only do it the other way round and have the cached portion in user controls. An example of the multimedia.aspx file logic may read something like this: run query to get parameters for this multimedia object using the session objectid variable as a parameter output html (ie table with colours) based upon this query (this is what i want to cache) then run query to get a list of .gifs from the database (they can change regularly so i want this dynamic) output html (not cached) -------------------------------------------------------------------------- ------ The same multimedia.aspx can appear twice (with the same session objectid as a parameter) on the same ASP page. In each multimedia.aspx page that gets passed a different session objectid the html output varys slightly (ie table colours etc.) Thanks. |
#3
| |||
| |||
|
|
One easy way to handle all that would be to use data caching. Create a "multimedia" user control that has an ObjectID property. The user control's code takes that objectid, calls the database, gets a dataset back, builds some HTML, & returns it. Your user control could cache the dataset e.g. Cache.Insert("dataset"+this.ObjectID,dsTheResults) Or it could build the HTML from the dataset & just cache the resulting HTML Cache.Insert("html"+this.ObjectID,strSomeHTML) The code would do the normal stuff of checking the cache for null, repopulating it as needed (maybe with delgates), etc. If you were set on using outputcaching you'd put the outputcache into the multimedia control, not the ASPX, & use one of the varyby* attributes. But I think that'll prove more trouble than it's worth in this situation. -- Ben Strackany www.developmentnow.com a href="http://www.developmentnow.com">dn</a "greg" <greg_platt (AT) hotmail (DOT) com> wrote in message news:uQRa8bz1EHA.1144 (AT) TK2MSFTNGP09 (DOT) phx.gbl... I have an ASP app that i'm porting over ASP.Net In an asp page i have many server.execute statements. So in the asp page code i have something like this % session("objectid") = 1001778 server.execute("multimedia.aspx") session("objectid") = 1001779 server.execute("multimedia.aspx") session("objectid") = 1001899 server.execute("listrecords.aspx") session("objectid") = 1001778 server.execute("multimedia.aspx") % Now i want only some code on the multimedia.aspx page to be cached as some of the queries on the page are dynamic. However i also want the page caching to vary based upon the objectid number in the session variable. (BTW i am using a method that allows ASP sessions to be shared with ASP.net sessions). what i don't quite understand is that if i set the OUTPUTCACHE at the top of page (in the .aspx file) to be cached and i use user controls in the ASPX page for the dynamic queries is it possible to set the user controls so they are not cached or .... can you only do it the other way round and have the cached portion in user controls. An example of the multimedia.aspx file logic may read something like this: run query to get parameters for this multimedia object using the session objectid variable as a parameter output html (ie table with colours) based upon this query (this is what i want to cache) then run query to get a list of .gifs from the database (they can change regularly so i want this dynamic) output html (not cached) -------------------------------------------------------------------------- ------ The same multimedia.aspx can appear twice (with the same session objectid as a parameter) on the same ASP page. In each multimedia.aspx page that gets passed a different session objectid the html output varys slightly (ie table colours etc.) Thanks. |
#4
| |||
| |||
|
|
Thanks, That sounds good but what i don't quite understand is how i cache around the dynamic stuff. For example in the multimedia.aspx I run a query based upon parameter (session variable) then i output html which you say i can cache. Problem is that the dynamic queries appear in the page logic inbetween the html i want to cache. So i run the first query then i might say something like this. % if object.recordcount=1 then %><%=html%><% // run dynamic query and output some dynamic html %><%=morehtml%><% else %><%=html%><% // run dynamic query here and output some dynamic html %><%=morehtml%><% end if % how do i easily cache the html around the dynamic queries? With your method wouldn't i require lots of cache inserts for each block of html? So ideally i would like to cache the aspx page but run some usercontrols (with no caching) to output the dynamic stuff I'm not sure if this is possible however. "Ben Strackany" <infoNOSPAM (AT) developmentnow (DOT) nospam.com> wrote in message news:up1W30z1EHA.1292 (AT) TK2MSFTNGP10 (DOT) phx.gbl... One easy way to handle all that would be to use data caching. Create a "multimedia" user control that has an ObjectID property. The user control's code takes that objectid, calls the database, gets a dataset back, builds some HTML, & returns it. Your user control could cache the dataset e.g. Cache.Insert("dataset"+this.ObjectID,dsTheResults) Or it could build the HTML from the dataset & just cache the resulting HTML Cache.Insert("html"+this.ObjectID,strSomeHTML) The code would do the normal stuff of checking the cache for null, repopulating it as needed (maybe with delgates), etc. If you were set on using outputcaching you'd put the outputcache into the multimedia control, not the ASPX, & use one of the varyby* attributes. But I think that'll prove more trouble than it's worth in this situation. -- Ben Strackany www.developmentnow.com a href="http://www.developmentnow.com">dn</a "greg" <greg_platt (AT) hotmail (DOT) com> wrote in message news:uQRa8bz1EHA.1144 (AT) TK2MSFTNGP09 (DOT) phx.gbl... I have an ASP app that i'm porting over ASP.Net In an asp page i have many server.execute statements. So in the asp page code i have something like this % session("objectid") = 1001778 server.execute("multimedia.aspx") session("objectid") = 1001779 server.execute("multimedia.aspx") session("objectid") = 1001899 server.execute("listrecords.aspx") session("objectid") = 1001778 server.execute("multimedia.aspx") % Now i want only some code on the multimedia.aspx page to be cached as some of the queries on the page are dynamic. However i also want the page caching to vary based upon the objectid number in the session variable. (BTW i am using a method that allows ASP sessions to be shared with ASP.net sessions). what i don't quite understand is that if i set the OUTPUTCACHE at the top of page (in the .aspx file) to be cached and i use user controls in the ASPX page for the dynamic queries is it possible to set the user controls so they are not cached or .... can you only do it the other way round and have the cached portion in user controls. An example of the multimedia.aspx file logic may read something like this: run query to get parameters for this multimedia object using the session objectid variable as a parameter output html (ie table with colours) based upon this query (this is what i want to cache) then run query to get a list of .gifs from the database (they can change regularly so i want this dynamic) output html (not cached) ------------------------------------------------------------------------- - ------ The same multimedia.aspx can appear twice (with the same session objectid as a parameter) on the same ASP page. In each multimedia.aspx page that gets passed a different session objectid the html output varys slightly (ie table colours etc.) Thanks. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |