0
我嘗試編寫一個方法,當它將用戶重定向到另一個控制器內的動作時。我使用return Redirect("~/" + redirectUrl + "/" + paymentInfo.ObjectIdDepartue);
陳述來做到這一點。並通過RedirectResult
,ActionResult
測試此方法的類型,但不工作。如何將用戶重定向到另一個控制器內部的動作
什麼是問題?
public RedirectResult PayViaCredit(int paymentId)
{
var paymentInfo = db.Payments.Find(paymentId);
//Decrease Credit
Profile userProfile = _utility.GetProfileOfUser();
decimal decreasedCredit = userProfile.Credit - paymentInfo.Price using (var transactionScope = new TransactionScope())
{
try
{
db.ProcUpdateProfileCredit(decreasedCredit, userProfile.UserId);
//Update Payment
paymentInfo.Transactionsuccess = true;
paymentInfo.state = 3;
paymentInfo.Confirmed = true;
db.Entry(paymentInfo).State = EntityState.Modified;
db.SaveChanges();
System.Web.HttpContext.Current.Session["InvoiceNumber"] = paymentInfo.Id.ToString();
transactionScope.Complete();
}
catch (Exception e)
{
_errorLog.Error("CreditPayment.cs/PayViaCredit", "", e.Source, "Message:::" + e.Message + "---InnerException:::" + e.InnerException);
transactionScope.Dispose();
}
}
string redirectUrl = _creditPayment.GetRedirectUrlCreditPayment(paymentInfo);
return Redirect("~/" + redirectUrl + "/" + paymentInfo.ObjectIdDepartue);
}
public ActionResult AfterPaymentBank()
{
return View();
}
'redirectUrl'是否包含絕對Url?無論如何,沒有理由使用'〜'來進行重定向。 – haim770
我的網址是〜/ Charter/AfterPaymentBank。我測試出來〜但不起作用 – programmer138200
你可以發佈AfterPaymnetBank行動的代碼嗎? – FakeisMe