第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

非異步調用異步方法時出錯

非異步調用異步方法時出錯

C#
楊__羊羊 2021-07-06 13:00:00
我有以下異步方法:[HttpGet][Route("api/SecurityRoles/AllowDeleteRole/{securityRoleId}")]public async Task<IHttpActionResult> AllowDeleteRole(int securityRoleId){    _systemLogger.LogInfo($"Method api/SecurityRoles/AllowDeleteRole (Get) called with securityRoleId: {securityRoleId}");    var securityRolePermission =            await _securityRolePermissionService.SecurityRolePermissionsCountBySecurityRoleId(securityRoleId);    if (securityRolePermission != SecurityRoleDeleteResult.Success) return Ok(SecurityRoleDeleteResult.RolePermissionExists);    var securityRolePageEntity =            await  _securityRolePageEntityService.SecurityRolePageEntityCountBySecurityRoleId(securityRoleId);    return Ok(securityRolePageEntity != SecurityRoleDeleteResult.Success ? SecurityRoleDeleteResult.RolePageEntityExists : SecurityRoleDeleteResult.Success);    }它在很多地方使用,但對于這個實例,我需要非異步地使用它,所以我有以下代碼首先包裝它:public async Task<SecurityRoleDeleteResult> AllowDeleteRole(int securityRoleId)    {        string url = $"{_housingDataSecurityConfiguration.HousingDataSecurityWebApiUrl}SecurityRoles/AllowDeleteRole/{securityRoleId}";        var message =  _apiClientService.Retrieve<HttpResponseMessage>(url);        if (message.StatusCode == HttpStatusCode.InternalServerError)        {            return SecurityRoleDeleteResult.ErrorOccurred;        }        int intResult = 0;        var apiResult = await message.Content.ReadAsStringAsync();        if (int.TryParse(apiResult, out intResult))        {            return (SecurityRoleDeleteResult)intResult;        }        else        {            return SecurityRoleDeleteResult.ErrorOccurred;        }    }我的問題是,當我嘗試EnableDeleteButton = enableButton在模型中進行設置時,它會在線上拋出以下錯誤:enableButton = (result.Result == SecurityRoleDeleteResult.Success) ? true : false;{"將值 3 轉換為類型 'System.Net.Http.HttpResponseMessage' 時出錯。路徑 '',第 1 行,位置 1。"}3 指的是我的 SecurityRoleDeleteResult 枚舉上的枚舉值之一。
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 202 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號