Using async (asynchronous) and await in ASP.Net MVC

mahesh213
 
on Sep 24, 2020 02:22 AM
521 Views

Hi,

I have one action method

i need to apply async and await keywords but here getting error

could you please help me how to apply 

async and await keywords on below action method 

[HttpGet]
public async Task<ActionResult> GetCompanyName()
{
    var comp = await(db.companies.Select(model => new { model.Id, model.Name }).ToList());
    return Json(comp, JsonRequestBehavior.AllowGet);
}

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download