5
Answers

How redirect to different view of same controller class?

Karan Thakkar

Karan Thakkar

5y
4.3k
1
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)