从我正在制作的网站的每个页面,您都可以登录。在其他表单的页面上,我在提交后收到以下错误:“不允许子操作执行重定向操作。”所有表单都正常工作,直到我添加登录。此外,登录时您可以正常使用它。仅当我提交其他表单时才会出现错误。我设置了一个断点,我看到了当我点击另一个提交时会发生什么。出于某种原因,SignIn Post ActionResult正在尝试运行。 任何帮助将不胜感激。
不允许子操作执行重定向操作。第67行:@ {Html.RenderAction(“SignIn”,“Account”);}
@using (Html.BeginForm("SignIn", "Account", FormMethod.Post))
{
<input class="signInSubmit" type="submit" name="submitButton" value="" />
}
@using (Html.BeginForm("Confirm", "Cart", null, FormMethod.Post, new { @id = "productDetailsForm" }))
{
<input class="addToCart" type="submit" name="submit" value="" />
}
// GET: /Account/SignIn
public ActionResult SignIn()
{
return PartialView();
}
// POST: /Account/SignIn
[HttpPost]
public ActionResult SignIn(Customer customer)
{
try
{
//Stuff is here
return RedirectToAction("Index", "Home");
}
catch
{
return RedirectToAction("Registration");
}
}
// GET: /Cart/
public ActionResult Index()
{
CartViewModel cart = getCart();
return View(cart);
}
//POST: Cart/Confirm
[HttpPost]
public ActionResult Confirm(int productID, bool certs, int quantity)
{
CartItemViewModel viewModel = new CartItemViewModel
{
Item = productRep.GetProductByID(productID),
Certs = certs,
Quantity = quantity
};
return View(viewModel);
}
<form action="/Account/SignIn" method="post">
<input class="signInSubmit" type="submit" value="" />
</form>
<form action="/Cart/Confirm" id="productDetailsForm" method="post">
<input class="addToCart" type="submit" value="" />
</form>
答案 0 :(得分:0)
我将POST ActionResult重命名为除SignIn之外的任何内容。有谁知道为什么这有效?
// POST: /Account/Signed
[HttpPost]
public ActionResult Signed(Customer customer)
{
try
{
//Stuff is here
return RedirectToAction("Index", "Home");
}
catch
{
return RedirectToAction("Registration");
}
}