Я создал веб-API, которые имеют ниже асинхронном действиявызов веб-API из браузера не работает с действием асинхронным
[ActionName("getFedCust")]
private async Task<HttpResponseMessage> getFedCust()
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri("http://fw.dev.test.com/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = await client.GetAsync("/api/fed");
return response;
}
}
мое имя контроллера ADAccount , когда я звоню из Chrome мое действие с помощью ниже маршрута браузера скажите, что он не может найти действие getFedCust http://localhost:55074/api/adaccount/getFedCust.
Я дал маршрут по умолчанию в WEBapiConfig.cs
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate:"api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
кстати, если я создать не действие асинхронной работает
public HttpResponseMessage getFedCust()
{
FedCust[] fedcust = new FedCust[]
{
new FedCust {name="Fabrikam"
,domains="fabrikam.local"
,sts="http://fabrikam.test.com/adfs/services/trust"
},
new FedCust {name="Contoso"
,domains="contoso.local"
,sts="http://contoso.test.com/adfs/services/trust"
}
};
return this.Request.CreateResponse(HttpStatusCode.OK, fedcust, "application/json");
}
любая помощь будет приветствоваться, как я довольно новичок в этой части
Определение "не работает". – LegionMammal978