Home Question.net question ASP.NET MVC Interview Question

ASP.NET MVC Interview Question

by Dhanik Lal Sahni

1. What is EmptyResult in MVC?

EmptyResult is used when you want to execute logic return inside the controller action method but does not want any result back to the view.

2. What is difference between returning EmptyResult and Null?

There is no functional difference between both. When we return NULL then also it return EmptyResult internally.

We should use EmptyResult as it communicates more clearly that your action returns nothing.

3. Can we overload controller methods in ASP.NET MVC?

We can use ActionName attribute to overload action method.

        public ActionResult LoadCustomer()
        {
            return Content("LoadCustomer");
        }
        [ActionName("LoadCustomerbyName")]
        public ActionResult LoadCustomer(string str)
        {
            return Content("LoadCustomer with a string");
        }

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.