0

This is the controller

[HttpGet]
public ActionResult EditMusicRecording(int Id)
{
    return View(_musicService.GetMusicRecording(Id));
}

[HttpPost]
public ActionResult EditMusicRecording(Music_Recording recording)
{
    try
    {
        _musicService.EditMusicRecording(recording);
        return RedirectToAction("Recordings");
    }
    catch
    {
        return View();
    }
}

The route

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Music", action = "Categories", id = UrlParameter.Optional }
);
Craig W.
  • 17,838
  • 6
  • 49
  • 82

1 Answers1

0

If EditMusicRecording don't pass id parameter throw this error.

This code is causing the error.

    catch
    {
        return View();
    }

Try this:

return RedirectToAction("EditMusicRecording", new { Id = 5 });
hakantopuz
  • 481
  • 5
  • 11