Skip to content

Commit 8b6e4f0

Browse files
committed
Added async Action in demo project (ref: #16)
1 parent ea42cf1 commit 8b6e4f0

File tree

4 files changed

+130
-130
lines changed

4 files changed

+130
-130
lines changed

DevTrends.MvcDonutCaching.Demo/Controllers/HomeController.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,25 @@ public ActionResult TestIssue23()
6161
return View();
6262
}
6363

64+
[DonutOutputCache(Duration = 3600 /* Bacon is still good one hour later */)]
6465
public async Task<ActionResult> WorksOnAsyncMethodsToo()
6566
{
6667
var req = WebRequest.Create("http://baconipsum.com/api/?type=meat-and-filler");
6768

68-
string[] final;
69+
string[] final = null;
6970

7071
using (var resp = await req.GetResponseAsync())
7172
{
72-
final = JsonConvert.DeserializeObject<string[]>(resp.ToString());
73+
var rStream = resp.GetResponseStream();
74+
if (rStream != null)
75+
{
76+
using (var r = new StreamReader(rStream))
77+
{
78+
final = JsonConvert.DeserializeObject<string[]>(r.ReadToEnd());
79+
}
80+
}
7381
}
74-
82+
7583
return View(final);
7684
}
7785
}

DevTrends.MvcDonutCaching.Demo/MvcDonutCaching.Demo.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<HintPath>..\packages\Microsoft.AspNet.WebPages.3.1.2\lib\net45\System.Web.Helpers.dll</HintPath>
105105
</Reference>
106106
<Reference Include="System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
107-
<SpecificVersion>False</SpecificVersion>
107+
<Private>True</Private>
108108
<HintPath>..\packages\Microsoft.AspNet.Mvc.5.1.2\lib\net45\System.Web.Mvc.dll</HintPath>
109109
</Reference>
110110
<Reference Include="System.Web.Optimization">
@@ -182,6 +182,7 @@
182182
<Content Include="Views\LoadTest\SmallOutPutGrandChildAction.cshtml" />
183183
<Content Include="Scripts\jquery-1.10.2.min.map" />
184184
<Content Include="Views\Home\TestIssue23.cshtml" />
185+
<Content Include="Views\Home\WorksOnAsyncMethodsToo.cshtml" />
185186
</ItemGroup>
186187
<ItemGroup>
187188
<Content Include="Views\Home\SimpleDonutOne.cshtml" />
Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
@model IEnumerable<string>
2-
3-
4-
<table>
5-
<tr>
6-
<th>Value</th>
7-
</tr>
8-
@foreach (var w in Model)
2+
@if (Model == null)
3+
{
4+
<p>Error while reading remote web service response</p>
5+
}
6+
else
7+
{
8+
<h1>Everybody loves bacon</h1>
9+
foreach (var ipsum in Model)
910
{
10-
<tr>
11-
<td>@w</td>
12-
</tr>
11+
<p>@ipsum</p>
1312
}
14-
</table>
13+
}

DevTrends.MvcDonutCaching.Demo/Web.config

Lines changed: 107 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -4,132 +4,124 @@
44
http://go.microsoft.com/fwlink/?LinkId=169433
55
-->
66
<configuration>
7-
<configSections>
8-
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
9-
</configSections>
10-
11-
12-
<appSettings>
13-
<add key="webpages:Version" value="2.0.0.0" />
14-
<add key="webpages:Enabled" value="false" />
15-
<add key="PreserveLoginUrl" value="true" />
16-
<add key="ClientValidationEnabled" value="true" />
17-
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
18-
</appSettings>
19-
<!--
7+
<configSections>
8+
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
9+
</configSections>
10+
<appSettings>
11+
<add key="webpages:Version" value="2.0.0.0" />
12+
<add key="webpages:Enabled" value="false" />
13+
<add key="PreserveLoginUrl" value="true" />
14+
<add key="ClientValidationEnabled" value="true" />
15+
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
16+
</appSettings>
17+
<!--
2018
Pour obtenir une description des modifications de web.config, voir http://go.microsoft.com/fwlink/?LinkId=235367.
21-
2219
Les attributs suivants peuvent être définis dans la balise <httpRuntime>.
2320
<system.Web>
2421
<httpRuntime targetFramework="4.5" />
2522
</system.Web>
2623
-->
27-
<system.web>
28-
<authentication mode="Forms" />
29-
<httpRuntime />
30-
<compilation debug="true" targetFramework="4.5" />
31-
<pages controlRenderingCompatibilityVersion="4.0">
32-
<namespaces>
33-
<add namespace="System.Web.Helpers" />
34-
<add namespace="System.Web.Mvc" />
35-
<add namespace="System.Web.Mvc.Ajax" />
36-
<add namespace="System.Web.Mvc.Html" />
37-
<add namespace="System.Web.Routing" />
38-
<add namespace="System.Web.WebPages" />
39-
</namespaces>
40-
</pages>
41-
<caching>
42-
<outputCacheSettings>
43-
<outputCacheProfiles>
44-
<remove name="medium" />
45-
<add name="medium" duration="600" varyByParam="*" location="Server" enabled="true" />
46-
</outputCacheProfiles>
47-
</outputCacheSettings>
48-
</caching>
49-
<!-- Glimpse: This can be commented in to add additional data to the Trace tab when using WebForms
24+
<system.web>
25+
<authentication mode="Forms" />
26+
<httpRuntime />
27+
<compilation debug="true" targetFramework="4.5" />
28+
<pages controlRenderingCompatibilityVersion="4.0">
29+
<namespaces>
30+
<add namespace="System.Web.Helpers" />
31+
<add namespace="System.Web.Mvc" />
32+
<add namespace="System.Web.Mvc.Ajax" />
33+
<add namespace="System.Web.Mvc.Html" />
34+
<add namespace="System.Web.Routing" />
35+
<add namespace="System.Web.WebPages" />
36+
</namespaces>
37+
</pages>
38+
<caching>
39+
<outputCacheSettings>
40+
<outputCacheProfiles>
41+
<remove name="medium" />
42+
<add name="medium" duration="600" varyByParam="*" location="Server" enabled="true" />
43+
</outputCacheProfiles>
44+
</outputCacheSettings>
45+
</caching>
46+
<!-- Glimpse: This can be commented in to add additional data to the Trace tab when using WebForms
5047
<trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false"/> -->
51-
<membership defaultProvider="XmlMembershipProvider">
52-
53-
<providers>
54-
<add name="XmlMembershipProvider" type="Artem.Web.Security.XmlMembershipProvider, Artem.Web.Security.Xml" applicationName="Test" enablePasswordReset="true" enablePasswordRetrieval="false" maxInvalidPasswordAttempts="5" minRequiredNonAlphanumericCharacters="0" minRequiredPasswordLength="4" passwordAttemptWindow="10" passwordFormat="Clear" passwordStrengthRegularExpression="" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" caseSensitive="false" useUniversalTime="false" fileName="Users.xml" folder="~/App_Data/" />
55-
</providers>
56-
</membership>
57-
<profile defaultProvider="XmlProfileProvider" enabled="false">
58-
59-
<providers>
60-
<add name="XmlProfileProvider" type="Artem.Web.Security.XmlProfileProvider, Artem.Web.Security.Xml" applicationName="Test" fileName="Profiles.xml" folder="~/App_Data/" />
61-
</providers>
62-
</profile>
63-
<roleManager enabled="true" defaultProvider="XmlRoleProvider">
64-
65-
<providers>
66-
<add name="XmlRoleProvider" type="Artem.Web.Security.XmlRoleProvider, Artem.Web.Security.Xml" applicationName="Test" caseSensitive="false" fileName="Roles.xml" folder="~/App_Data/" />
67-
</providers>
68-
</roleManager>
69-
70-
71-
72-
<!-- Glimpse: This can be commented in to add additional data to the Trace tab when using WebForms
48+
<membership defaultProvider="XmlMembershipProvider">
49+
<providers>
50+
<clear/>
51+
<add name="XmlMembershipProvider" type="Artem.Web.Security.XmlMembershipProvider, Artem.Web.Security.Xml" applicationName="Test" enablePasswordReset="true" enablePasswordRetrieval="false" maxInvalidPasswordAttempts="5" minRequiredNonAlphanumericCharacters="0" minRequiredPasswordLength="4" passwordAttemptWindow="10" passwordFormat="Clear" passwordStrengthRegularExpression="" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" caseSensitive="false" useUniversalTime="false" fileName="Users.xml" folder="~/App_Data/" />
52+
</providers>
53+
</membership>
54+
<profile defaultProvider="XmlProfileProvider" enabled="false">
55+
<providers>
56+
<clear/>
57+
<add name="XmlProfileProvider" type="Artem.Web.Security.XmlProfileProvider, Artem.Web.Security.Xml" applicationName="Test" fileName="Profiles.xml" folder="~/App_Data/" />
58+
</providers>
59+
</profile>
60+
<roleManager enabled="true" defaultProvider="XmlRoleProvider">
61+
<providers>
62+
<clear/>
63+
<add name="XmlRoleProvider" type="Artem.Web.Security.XmlRoleProvider, Artem.Web.Security.Xml" applicationName="Test" caseSensitive="false" fileName="Roles.xml" folder="~/App_Data/" />
64+
</providers>
65+
</roleManager>
66+
<!-- Glimpse: This can be commented in to add additional data to the Trace tab when using WebForms
7367
<trace writeToDiagnosticsTrace="true" enabled="true" pageOutput="false"/> -->
74-
<httpModules>
75-
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
76-
</httpModules>
77-
<httpHandlers>
78-
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
79-
</httpHandlers>
80-
</system.web>
81-
<runtime>
82-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
83-
<!--
68+
<httpModules>
69+
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
70+
</httpModules>
71+
<httpHandlers>
72+
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
73+
</httpHandlers>
74+
</system.web>
75+
<runtime>
76+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
77+
<!--
8478
System.Web Assembly redirects are needed by MvcDonutCaching with MVC 4 (The library is linked against System.Web.Mvc 3.0)
8579
Without that, DonutCacheAttribute will be ignored.
8680
-->
87-
<!-- Added by Autofac -->
88-
<dependentAssembly>
89-
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
90-
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
91-
</dependentAssembly>
92-
<dependentAssembly>
93-
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
94-
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
95-
</dependentAssembly>
96-
<dependentAssembly>
97-
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
98-
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
99-
</dependentAssembly>
100-
<dependentAssembly>
101-
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
102-
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
103-
</dependentAssembly>
104-
<dependentAssembly>
105-
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
106-
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
107-
</dependentAssembly>
108-
<dependentAssembly>
109-
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
110-
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
111-
</dependentAssembly>
112-
<dependentAssembly>
113-
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
114-
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
115-
</dependentAssembly>
116-
</assemblyBinding>
117-
</runtime>
118-
119-
120-
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
121-
<!--
81+
<!-- Added by Autofac -->
82+
<dependentAssembly>
83+
<assemblyIdentity name="Autofac" publicKeyToken="17863af14b0044da" culture="neutral" />
84+
<bindingRedirect oldVersion="0.0.0.0-3.3.0.0" newVersion="3.3.0.0" />
85+
</dependentAssembly>
86+
<dependentAssembly>
87+
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
88+
<bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" />
89+
</dependentAssembly>
90+
<dependentAssembly>
91+
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
92+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
93+
</dependentAssembly>
94+
<dependentAssembly>
95+
<assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" />
96+
<bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" />
97+
</dependentAssembly>
98+
<dependentAssembly>
99+
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
100+
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
101+
</dependentAssembly>
102+
<dependentAssembly>
103+
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
104+
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
105+
</dependentAssembly>
106+
<dependentAssembly>
107+
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
108+
<bindingRedirect oldVersion="0.0.0.0-5.1.0.0" newVersion="5.1.0.0" />
109+
</dependentAssembly>
110+
</assemblyBinding>
111+
</runtime>
112+
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
113+
<!--
122114
For more information on how to configure Glimpse, please visit http://getglimpse.com/Help/Configuration
123115
or access {your site}/Glimpse.axd for even more details and a Configuration Tool to support you.
124116
-->
125-
</glimpse>
126-
<system.webServer>
127-
<validation validateIntegratedModeConfiguration="false" />
128-
<modules>
129-
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
130-
</modules>
131-
<handlers>
132-
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
133-
</handlers>
134-
</system.webServer>
135-
</configuration>
117+
</glimpse>
118+
<system.webServer>
119+
<validation validateIntegratedModeConfiguration="false" />
120+
<modules>
121+
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
122+
</modules>
123+
<handlers>
124+
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
125+
</handlers>
126+
</system.webServer>
127+
</configuration>

0 commit comments

Comments
 (0)