将表单 post 重定向到另一个视图时出现问题

Having a problem redirecting a form post to another view

我有一个基本的 MVC 表单,允许用户提交邮政编码,点击提交后,用户应该被重定向到一个新视图。我的代码似乎成功重定向到下一个操作。但是在重定向之后,控制器 return 返回到原始操作,因此对于用户来说,接下来的页面完全改变了。

这是我的查看代码:

@using (Html.BeginForm("PricingQuote", "Home", FormMethod.Post, new { @class = "rd-mailform text-center offset-top-30" }))
{
     <div class="form-group">
          <label class="form-label" for="contact-zip">Zip Code</label>
          <input class="form-control" id="contact-zip" type="text" name="zip" data-constraints="@@Required">
     </div>
     <button class="btn btn-primary offset-top-30" type="submit">GET STARTED</button>
 }

这是我 HomeController 中的 PricingQuote 动作。此操作重定向到我的 Pricing 控制器中的 Pricing 操作:

[HttpPost]
public ActionResult PricingQuote(string zipCode)
{
    return RedirectToAction("Pricing", "Pricing");
}

这是我的 PricingController:

public class PricingController : Controller
{
    // GET: Pricing
    public ActionResult Pricing()
    {
        return View();
    }
}

因此,在单击 开始使用 后,它会访问我的 Home/PricingQuote 操作。然后此操作尝试重定向到 Pricing/Pricing 操作,但它确实这样做了,然后代码似乎(错误地)return 回到 Home/PricingQuote 并退出操作。

知道如何重定向和显示我的 Pricing 视图吗?

谢谢

将控制器作为第二个参数传入:

[HttpPost]
public ActionResult PricingQuote(string zipCode)
{
    return RedirectToAction("Pricing", "PricingController");
}

感谢您的回复。我能够弄清楚我的问题。我试图重定向到的操作名称(“定价”)与我的控制器(“定价”)同名。作为测试,我将我的动作重命名为“PricingA”并且它起作用了,所以显然基于此,在尝试“RedirectToAction”时动作不能与控制器同名,我不知道(至少这是我的假设根据我找到的结果)。

不幸的是,我尝试在谷歌上搜索一些额外的证据来提供这个答案,但找不到任何证据。

这个有效:

家庭控制器:

[HttpPost]
 public ActionResult PricingQuote(string zipCode)
 {
    return RedirectToAction("PricingA", "Pricing");
 }

定价控制器

 [HttpGet]
    public ActionResult PricingA()
    {
        return View();
    }