HOW TO REDIRECT A USER CONTROL TO THE VIEW ITS CALLED FROM?

Pravesh Singh

Total Post:412

Points:2888
Posted by  Pravesh Singh
 1035  View(s)
Ratings:
Rate this:

I have a user control that creates a new record in a database. After it creates the new record, I would like to redirect it back to the view its from. The purpose of this is to refresh the view so that it can show the newly created record. The problem is that user control can exists in more than one view, so how can i know which view is the user control from? so that I can achieve the above scenario? Thanks

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: How to redirect a user control to the view its called from?

    Hi Pravesh, 

    try this:

    public ActionResult Save(SomeModel model)

    {

       db.Save(model);

       return RedirectToAction("Index");

    }

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!