Skip to content

Instantly share code, notes, and snippets.

@pageaffairs
Created February 4, 2021 00:03
Show Gist options
  • Save pageaffairs/91f2a6f31dec4e9af8c949d690bab7b2 to your computer and use it in GitHub Desktop.
Save pageaffairs/91f2a6f31dec4e9af8c949d690bab7b2 to your computer and use it in GitHub Desktop.
ASP.NET application snippet: 4
public class MyApiController : ApiController
{
// Top-level method
public ActionResult HandleRESTApiCall(){
SomeType someObj = DoSomethingAsync().Result;
return OkResult(someObj);
}
private async Task<SomeType> DoSomethingAsync(){
var someData = await GetDataAsync();
return new SomeType(someData);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment