File tree Expand file tree Collapse file tree 6 files changed +63
-16
lines changed
DevTrends.MvcDonutCaching.Demo Expand file tree Collapse file tree 6 files changed +63
-16
lines changed Original file line number Diff line number Diff line change 11using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using System . Web ;
52using System . Web . Mvc ;
63
74namespace DevTrends . MvcDonutCaching . Demo . Controllers
85{
96 public class HomeController : Controller
107 {
8+ public ActionResult Index ( )
9+ {
10+ return RedirectToAction ( "Simple" ) ;
11+ }
12+
1113 //
1214 // GET: /Home/
1315 [ DonutOutputCache ( Duration = 24 * 3600 ) ]
14- public ActionResult Index ( )
16+ public ActionResult Simple ( )
1517 {
1618 return View ( DateTime . Now ) ;
1719 }
20+
21+ [ ChildActionOnly , DonutOutputCache ( Duration = 60 ) ]
22+ public ActionResult SimpleDonutOne ( )
23+ {
24+ return PartialView ( DateTime . Now ) ;
25+ }
26+
27+ [ ChildActionOnly ]
28+ public ActionResult SimpleDonutTwo ( )
29+ {
30+ return PartialView ( DateTime . Now ) ;
31+ }
1832 }
1933}
Original file line number Diff line number Diff line change 149149 </Content >
150150 <Content Include =" Views\Web.config" />
151151 </ItemGroup >
152- <ItemGroup />
152+ <ItemGroup >
153+ <Content Include =" Views\Home\SimpleDonutOne.cshtml" />
154+ </ItemGroup >
153155 <ItemGroup >
154156 <Content Include =" packages.config" >
155157 <SubType >Designer</SubType >
162164 </ProjectReference >
163165 </ItemGroup >
164166 <ItemGroup >
165- <Content Include =" Views\Home\Index .cshtml" />
167+ <Content Include =" Views\Home\Simple .cshtml" />
166168 </ItemGroup >
167169 <ItemGroup >
168170 <Content Include =" Views\_ViewStart.cshtml" />
182184 <ItemGroup >
183185 <Content Include =" Views\Account\ChangePassword.cshtml" />
184186 </ItemGroup >
187+ <ItemGroup >
188+ <Content Include =" Views\Home\SimpleDonutTwo.cshtml" />
189+ </ItemGroup >
185190 <PropertyGroup >
186191 <VisualStudioVersion Condition =" '$(VisualStudioVersion)' == ''" >10.0</VisualStudioVersion >
187192 <VSToolsPath Condition =" '$(VSToolsPath)' == ''" >$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath >
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ @model DateTime
2+ @{
3+ ViewBag .Title = " Donut holes demo" ;
4+ }
5+
6+ <h2 >@ViewBag.Title </h2 >
7+
8+ <p >
9+ This page has been rendered at @Model (expires in 24h)
10+ </p >
11+
12+ <div >
13+ @Html.Action( "SimpleDonutOne", true)
14+ </div >
15+
16+ <p >
17+ This is again the main page
18+ </p >
19+
20+ <div >
21+ @Html.Action( "SimpleDonutTwo", true)
22+ </div >
23+
24+ <p >
25+ This is again again the main page
26+ </p >
Original file line number Diff line number Diff line change 1+ @model DateTime
2+
3+ <p >
4+ Donut rendered at : @Model (expires every 60 seconds)
5+ </p >
Original file line number Diff line number Diff line change 1+ @model DateTime
2+
3+ <p >
4+ This is another donut, not cached at all
5+ <br />
6+ Generated at : @Model
7+ </p >
You can’t perform that action at this time.
0 commit comments