0

コントローラー関数の呼び出しに小さな問題があります。奇妙なのは、他のすべての送信ボタンが正常に機能することです。しかし、これには今のところ解決できない問題があります。正常に機能しているのは 1 つだけなので、送信ボタンのある 2 つのフォームを示します。

コントローラ:

public class MyController : Controller
{
    public ActionResult MethodOne()
        {
            ...
            return RedirectToAction("index");
        }

    public ActionResult MethodTwo()
        {
            ...
            return RedirectToAction("index");
        }
}

そしてビュー:

//This one works fine!!
@using (Html.BeginForm("MethodOne", "My", FormMethod.Post))
{
    <input id="Some-cool-id" type="submit" value="Add!" />
}

//This one doesn't work?!
@using (Html.BeginForm("MethodTwo", "My", FormMethod.Post))
{
    <input id="some-cool-id2" type="submit" value="Delete"!" />
}

エラーは、Method2 が必要なパスにないことを示しています。

Resource not found.

Description: HTTP 404. Searched resource (or ...) ... 

Required path URL: /My/MethodTwo

何が悪いのか探していましたが、結局、助けが必要です、ありがとう。

4

2 に答える 2

0

これを試して、

  @using (Html.BeginForm("MethodTwo", "Test", FormMethod.Post))
    {
        <input type="submit" value="asd" />
    }


     @using (Html.BeginForm("MethodOne", "Test", FormMethod.Post))
    {
        <input type="submit" value="poll" />
    }

コントローラ

 public class TestController : Controller
    {

 public ActionResult MethodOne()
        {

        return RedirectToAction("CustomerInfo");
    }

    public ActionResult MethodTwo()
    {

        return RedirectToAction("CustomerInfo");
    }

 [HttpGet]
        public ActionResult CustomerInfo()
        {

        ViewBag.CustomerNameID = new SelectList(List, "CustomerId", "customerName");
        ViewBag.RegisterItems = GetAllRegisterData();
        ViewData["SampleList"] = GetAllRegisterData();
        return View();
    }
}
于 2013-08-30T13:22:14.107 に答える