Karan Thakkar

Karan Thakkar

  • 1.6k
  • 171
  • 3.1k

How redirect to different view of same controller class?

May 4 2019 8:57 AM
I have a ActionMethod which I called on Submit  button
public Submit ActionResult(Employee emp)
{
emp object has all data like name,emailid, mobileNo etc 
--calling business layer to insert data in database
 
i want to return a view here which is of same controller class I tried it in following ways 
return view("ViewName",emp);
 
in this case i dont have any action name and I redirected to view successfully
but the problem is when I refresh that view it hits to  Submits and again entry is made in
database. 
 
return RedirectToAction("ActionName",ViewName,emp);
 
here i have action which redirects to same view i.e "ViewName" 
but in this case it fails to redirect 
 
Thanks.
 

Answers (5)