Difference between ViewResult and ActionResult


 ViewResult and ActionResult



       ActionResult is an abstract class that can have several subtypes.
       ViewResult - Renders a specifed view to the response stream

c# code for :
       public ViewResult Result()        {
            SHIFT_MAST _shift = new SHIFT_MAST();
            _shift.shift_cd = "1";
            _shift.shift_id = 2;
            _shift.start_time = "8.30";
            return View("Result", _shift);
        }

        public ActionResult ResultAction()
        {
            SHIFT_MAST _shift = new SHIFT_MAST();
            _shift.shift_cd = "1";
            _shift.shift_id = 2;
            _shift.start_time = "8.30";
            return View("ResultAction", _shift);
        }

ActionResult is an abstract class and its base class for ViewResult class
In MVC , it uses ActionResult class to reference the object your action method returns and invokes ExecuteResult method on it.
And ViewResult is an implementation for this abstract class. It will try to find a view page (usually aspx page) in some predefined paths(/views/controllername/, /views/shared/, etc) by the given view name.


Comments

Popular posts from this blog

Add Serial no in crystal report without coding

Working with Oracle's BLOB and Microsoft's C#

File operations in C# (.net)