async / await返回异常Threading.Tasks.Task`1 [System.Web.Mvc.ActionResult]异常

时间:2014-12-12 07:58:01

标签: asp.net-mvc-4 async-await c#-5.0

我已经使用Async和Await实现了一个ActionMethod,结果是Task< ActionResult>

[Route("Newdiaries/NewTestAsync")]
public async Task<ActionResult> Index()
{
    var countryId = Nationalizator.CurrentCountryId;
    var cultureCode = DomainCulture.Current.LCID;

    var channel = GetCandidateServiceChannel("WSHttpBinding_ICandidateService");

    IndividualPersonalInformationDto res = await channel.GetNewIndividualPersonalInformationAsync(new Guid("31764EC2-663D-C996-DB46-08D11B0047E5"), countryId, cultureCode).ConfigureAwait(false);
    var model = new MyTestModel
    {
        Name = res.BusinessId
    };

    return View("NewTestIndex",model);
}

它正在抛出 System.Threading.Tasks.Task 1 [System.Web.Mvc.ActionResult]`

我正在使用Visualstudio 2012和.Net 4.5 Framework。请帮忙。

1 个答案:

答案 0 :(得分:-1)

我认为问题在于你是从HttpContextThread切换,请尝试删除.ConfigureAwait(false),我认为它会解决你的问题:)