Trigger view rendering asynchronously.
This is as simple as modifying the base class to return task and await the ExecuteAsync method. Also added a piece to the sample project to verify functionality.
This commit is contained in:
parent
0247c3a393
commit
f8179f03e4
|
|
@ -6,6 +6,13 @@
|
|||
string nullValue = null;
|
||||
}
|
||||
|
||||
@functions {
|
||||
public async Task<string> AsyncValueRetrieval()
|
||||
{
|
||||
return "Hello World";
|
||||
}
|
||||
}
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>ASP.NET</h1>
|
||||
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
|
||||
|
|
@ -13,7 +20,8 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<h3 title="@Model.Name" class="@nullValue">Hello @Model.Name! Happy @Model.Age birthday.</h3>
|
||||
|
||||
<h3>This value was retrieved asynchronously: @(await AsyncValueRetrieval())</h3>
|
||||
|
||||
<div class="col-md-4">
|
||||
<h2>Getting started</h2>
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
_baseType = baseType;
|
||||
DefaultBaseClass = baseType + "<dynamic>";
|
||||
GeneratedClassContext = new GeneratedClassContext(
|
||||
executeMethodName: "Execute",
|
||||
executeMethodName: "ExecuteAsync",
|
||||
writeMethodName: "Write",
|
||||
writeLiteralMethodName: "WriteLiteral",
|
||||
writeToMethodName: "WriteTo",
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
using (var bodyWriter = new StringWriter(contentBuilder))
|
||||
{
|
||||
Output = bodyWriter;
|
||||
Execute();
|
||||
await ExecuteAsync();
|
||||
}
|
||||
|
||||
var bodyContent = contentBuilder.ToString();
|
||||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Mvc.Razor
|
|||
await layoutView.RenderAsync(context, writer);
|
||||
}
|
||||
|
||||
public abstract void Execute();
|
||||
public abstract Task ExecuteAsync();
|
||||
|
||||
public virtual void Write(object value)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue