I have an existing asp.net application and trying to migrate it to netcoreapp2.1 (MVC). The following code posts to external URL in asp.net application
if (DisplayType.SelectedValue == "1")
{
Form.Action = txt_payment_gateway_url.Text;
}
else if (DisplayType.SelectedValue == "2")
{
RedirectionURL.Value = txt_payment_gateway_url.Text;
}
in asp.net core appliction im using this code to post the encryptd request to external apllication
var result = PostEncryptedData(data, VM.PaymentGatewayURL);
private async Task<HttpResponseMessage> PostEncryptedData1(Dictionary<string, string> encryptedData, string url)
{
HttpClient client = new HttpClient();
List<KeyValuePair<string, string>> keyValuePairs = encryptedData.ToList();
var content = new FormUrlEncodedContent(keyValuePairs);
content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
return await client.PostAsync(url, content);
}
but during debug, it give me the result is not computed as shown Result is not computed
it has to be var result = await PostEncryptedData(data, VM.PaymentGatewayURL);
. you missed the await
Public async Task<your required return type> YourMethodName()
{
var result = await PostEncryptedData(data, VM.PaymentGatewayURL);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.