15.08.2013 Views

Ektron CMS400.NET Developer Reference Manual

Ektron CMS400.NET Developer Reference Manual

Ektron CMS400.NET Developer Reference Manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introduction to <strong>Ektron</strong> <strong>CMS400.NET</strong> Server Controls<br />

Below is an example of a page level cache for non logged in users.<br />

In this example, you use a Server Control to define whether a user<br />

is logged in or not. Then, further define if the time is cached, based<br />

on the user’s status.<br />

1. Create a new Web form in your <strong>Ektron</strong> <strong>CMS400.NET</strong> project.<br />

2. Add the following text to the Web form:<br />

Refresh the page. The page will cache for 20 seconds<br />

when not logged in:<br />

Time is =<br />

3. Next to Time is =, add a literal.<br />

4. Below that, add a ContentBlock Server Control.<br />

5. Set the DefaultContentID. For this example, DefaultContentID<br />

= 20.<br />

6. Add the following code to the code behind.<br />

If Not ContentBlock1.IsLoggedIn Then<br />

End If<br />

Response.Cache.SetExpires(DateTime.Now.AddSeconds(20))<br />

Response.Cache.SetCacheability(HttpCacheability.Public)<br />

Response.Cache.SetValidUntilExpires(True)<br />

Response.Cache.VaryByParams("id") = True<br />

Response.Cache.SetVaryByCustom("cmsCache")<br />

Literal1.Text = Now()<br />

7. Build your Web form.<br />

8. Browse to your Web form with your browser.<br />

<strong>Ektron</strong> <strong>CMS400.NET</strong> <strong>Developer</strong> <strong>Reference</strong> <strong>Manual</strong>, Version 5.1, Revision 5 60

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!