title: Async lambda expression converted to a 'Task' returning delegate cannot return a value
body: <p>I have the following in an ASP.NET Core application (<code>Startup.cs</code>, <code>Configure</code> method): </p>
  
  <p>I just added the <code>async</code> keyword, because I needed the <code>await</code> one... 
  So now, I am getting the following:</p>
  
  <blockquote>
    <p>Error CS8031  Async lambda expression converted to a '<code>Task</code>' returning
    delegate cannot return a value. Did you intend to return '<code>Task&lt;T&gt;</code>'?</p>
  </blockquote>
  
  <pre><code>public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ITableRepositories repository)
  {
      // ...  
      app.UseStaticFiles();    
      app.UseCookieAuthentication();
  
      app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
      {
          ClientId = Configuration["..."],
          Authority = Configuration["..."],
          CallbackPath = Configuration["..."],
          Events = new OpenIdConnectEvents
          {
              OnAuthenticationFailed = context =&gt; { return Task.FromResult(0); },
              OnRemoteSignOut = context =&gt; { return Task.FromResult(0); },
              OnTicketReceived = async context =&gt;
              {
                  var user = (ClaimsIdentity)context.Ticket.Principal.Identity;
                  if (user.IsAuthenticated)
                  {
                      var firstName = user.FindFirst(ClaimTypes.GivenName).Value;
                      // ...
                      List&lt;Connection&gt; myList = new List&lt;Connection&gt;() { c };
                      var results = await repository.InsertOrMergeAsync(myList);
                      var myConnection = (results.First().Result as Connection);                         
                  }
                  return Task.FromResult(0); // &lt;&lt;&lt; ERROR HERE ....... !!!
              },
              OnTokenValidated = context =&gt; { return Task.FromResult(0); },
              OnUserInformationReceived = context =&gt; { return Task.FromResult(0); },
          }
      });
  
      app.UseMvc(routes =&gt;        { ...        });
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/OyiuE.png" rel="noreferrer"><img src="https://i.stack.imgur.com/OyiuE.png" alt="enter image description here"></a></p>
  
  <p>What should I return in that case? I tried to <code>return 0;</code>, but the error message doesn't change...</p>
  
  <p>PS. The <code>OnTicketRecieved</code> signature</p>
  
  <pre><code>namespace Microsoft.AspNetCore.Authentication
  {
      public class RemoteAuthenticationEvents : IRemoteAuthenticationEvents
      {
          public Func&lt;TicketReceivedContext, Task&gt; OnTicketReceived { get; set; }
  </code></pre>