How to redirect to a PartialViewResult

2019-09-08 15:07发布

问题:

How do I redirect to a PartialViewResult? I am having the error message:

Error 1 'MvcUI.Controllers.ExpenseController.SaveAuthorization(string)': not all code paths return a value

public ActionResult SaveAuthorization(string ExpenseID)
     {

         RedirectToAction("AuthorizeEmployee");             
     }

     public PartialViewResult AuthorizeEmployee()
     {
         AuthorizeExpenseModel model = new AuthorizeExpenseModel(null, 0, "All");
         return PartialView("AuthorizeExpense_Details", model);
     }

回答1:

You need to put

return RedirectToAction("AuthorizeEmployee");

in your SaveAuthorization action