Wednesday, July 31, 2013

MVC Internal Controller Action Method with No View with No direct Browser Access

Sometimes we would like to call controller action method from View without the method completely tied to view. What I mean is direct browser access such as http://localhost/Home/GetCustomer/2
Now we have scenario where we want such action method to rendered partial view using html.action() that in turns calls Action method in controller. For such cases we have [ChildOnlyAction]attribute.

View-> html.action -> Calls Action Controller -> loads partial view

public ActionResult CanOnlyBeCalledInternalByView()

    return PartialView();
Post a Comment