Returning partial view from controller

 I want to return studentlist as a partial view. Here is my index method code 

  public ActionResult Index(Student Model)
        {
            using (var ctx = new School_Context())
            {
                ctx.Students.Add(Model);
                ViewBag.msg = "Record Saved!!";
                ctx.SaveChanges();
                return PartialView("StudentList");
            }
        }

But I don’t know where the problem is? When I run this code it shows error that view is not found.

Last updated:9/16/2017 5:26:19 AM

1 Answers

Sushant Mishra
Sushant Mishra

Check that your partial view should be in shared folder and shared folder should be in views folder not in Home folder as shown in below screenshot.



I hope your problem will be solved after reading this post.



Answer