我正在使用这个库为孟加拉国支付网关。https://github.com/Rahim373/Arts.SslCommerze .But代码在一个控制器等待iis无限的时间。如果响应是从服务器到达我的机器的话,我签入了fiddler。它已经够到了。但是异步函数没有执行。我的代码是:
public ActionResult About()
{
string customerName = "Fahim Abrar";
string customerEmail = "fahimabrar13@gmail.com";
string customerPhone = "+8801853912845";
string transactionId = "45c2ffc4d";
string successUrl = "http://fahimabrar.com";
string failUrl = "http://fahimabrar.com";
string cancelUrl = "cancelUrl";
decimal amount = 50;
Customer customer = new Customer(customerName, customerEmail,
customerPhone);
EmiTransaction emiTransaction = new
EmiTransaction(isEmiEnabled: false);
Trasnaction trasnaction = new Trasnaction(amount,
transactionId, successUrl, failUrl,
cancelUrl, emiTransaction, customer);
SslRequest.GetSessionAsync(trasnaction).ConfigureAwait(continueOnCapturedContext: false);
var session = SslRequest.GetSessionAsync(trasnaction).Result;
string s = session.FailedReason;
ViewBag.Message = s;
//"Your application description page.";
return View();
}在这里,var session = SslRequest.GetSessionAsync(trasnaction).Result;--这一行将导致死锁。
发布于 2018-11-03 06:29:35
.Result会导致死锁。
使您的方法async并使用await。
public async Task<ActionResult> About()
{
string customerName = "Fahim Abrar";
string customerEmail = "fahimabrar13@gmail.com";
string customerPhone = "+8801853912845";
string transactionId = "45c2ffc4d";
string successUrl = "http://fahimabrar.com";
string failUrl = "http://fahimabrar.com";
string cancelUrl = "cancelUrl";
decimal amount = 50;
Customer customer = new Customer(customerName, customerEmail,
customerPhone);
EmiTransaction emiTransaction = new
EmiTransaction(isEmiEnabled: false);
Trasnaction trasnaction = new Trasnaction(amount,
transactionId, successUrl, failUrl,
cancelUrl, emiTransaction, customer);
var session = await SslRequest.GetSessionAsync(trasnaction);
string s = session.FailedReason;
ViewBag.Message = s;
//"Your application description page.";
return View();
}https://stackoverflow.com/questions/53128879
复制相似问题