Reputation: 6781
I have done some searching on the error but the results all have to do with using try..catch
or if
statements. In my case I am just adding some info to the DB and then doing a RedirectToAction
call, I figure since I am not technically calling the return
keyword this is the root of the problem but what am I supposed to return and where when all I want to do is the redirect?
[Route("AddMTNLoctionNote", Name = "Add Location Note")]
public ActionResult AddMTNLocationNote()
{
using (var db = new JobSightDbContext())
{
var newNote = new MTNAlarmLocationNote()
{
LocationID = int.Parse(Request["LocationID"]),
Note = Request["Note"]
};
db.MTNAlarmLocationNotes.Add(newNote);
db.SaveChanges();
}
RedirectToAction("MTNAlarmDetail", int.Parse(Request["LocationID"]));
}
Upvotes: 3
Views: 1251
Reputation: 19526
You need to return
RedirectToAction()
's result, not just call the method:
return RedirectToAction("MTNAlarmDetail", int.Parse(Request["LocationID"]));
Upvotes: 19