Home > DeveloperSection > Forums > What is difference between return View() and return base.View() in C#?
Ashish Pandey

Total Post:128

Points:898
Posted on    September-21-2013 6:49 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 918  View(s)
Rate this:

My base controller is below:

public class BaseController : Controller

{

    public BaseController()

    {

    }

}

My Home controller is below:

public class HomeController : BaseController

{

    public ActionResult Index()

    {

        return View();

    }

    public ActionResult Login()

    {

        ActionResult action = base.View("Login");

        return action;

    }

}

My question is what is main difference between base.View() and View()? Is there any performance constrain or any other concern?



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-21-2013 7:46 AM

Hi Ashish,

Well, it depends whether you want to call the overridden version if there is one. If you absolutely know when you write the code that you don't want to call an overridden version, call base.MyMethod(). If you want to use whatever version has been provided by the class, call this.MyMethod() or just MyMethod().

Don't want to miss updates? Please click the below button!

Follow MindStick