0

here is the problem

 public ActionResult One()
 {
   if(condition)
     return View()
   else
     return Two()
 }

 public ActionResult Two()
 {
   return View()
 }

how can I do that without error

1
  • 1
    What error? I suggest explicitly saying the views name, like View("name") Commented Jul 18, 2012 at 8:55

4 Answers 4

3

Change your code to:

public ActionResult One()
 {
   if(condition)
     return View();
   else
     RedirectToAction("Two");
 }

 public ActionResult Two()
 {
   return View();
 }
Sign up to request clarification or add additional context in comments.

Comments

2

Just return the view by name (return view("nameOfView")), or use RedirectToAction or RedirectToRoute

Comments

2

Simply use:

 public ActionResult One()
 {
   if(condition)
     return View()
   else
     return View("Two")
 }

Comments

1

oh I've solved the problem

 public ActionResult Two()
 {
   return View("Two")
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.