The module when consuming a local web api (http://localhost/ConsultaVarias/Api/Distrito) it gives me the following error:
System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]
The problem is in async:
My Action:
public async Task Index() { var httpClient = new HttpClient(); var json = await httpClient.GetStringAsync("http://localhost/ConsultaVarias/Api/Distrito"); var distrito = JsonConvert.DeserializeObject>(json); return View(distrito); }
My API:
namespace ConsultasVarias.Controllers { public class DistritoController : ApiController { [HttpGet] public List ListarDistritos() { List distritos = null; try { SAT.ConsultasVarias oBLL = new SAT.ConsultasVarias(); DataTable dtDsitrito = oBLL.ListarDistritos(FuncionesWEB.GetConexionSoporteWEB()).Tables[0]; distritos = (from DataRow dr in dtDsitrito.Rows select new DistritoCLS() { vDistrito = dr["vDistrito"].ToString() }).ToList(); } catch (Exception ex) { //log.Error("TraceMessage:" + ex.StackTrace); } return distritos; } } }
Result
Test in MVC
Posted By Omar Sánchez on 10/27/2023 4:53 PM I am creating a module for DNN (VS 2017 + Christoc.com) that must consume a Web API because I cannot consume DCOM.
Hey Omar, I have to ask... Why are you using VS 2017 and what in your application requires DCOM?
These Forums are dedicated to the discussion of DNN Platform.
For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:
Awesome! Simply post in the forums using the link below and we'll get you started.