简体   繁体   中英

asp.net mvc3 return another view

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

Change your code to:

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

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

只需按名称return view("nameOfView")return view("nameOfView") ),或使用RedirectToActionRedirectToRoute

Simply use:

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

oh I've solved the problem

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM