Child Action Attribute in ASP.NET MVC 4

What is ChildActionOnly?

The ChildActionOnly attribute ensures that an action method can be called only as a child method from within a view.

Where to use ChildActionOnly?

  • ChildActionOnly it related with partial views but it is not compulsory.If decided to not access through url then we may declare as ChildActionOnly
  • This attribute used to prevent the action methods,being invoked as a result of a user request ,that is it prevent from accessing via url

public ActionResult GetUserDetails(int userId)
//Your Logic Here !!!
return PartialView(“GetUserDetails”, null);


calling this by

@Html.Action(“GetUserDetails”, “ChildActionTesting”)

By Sriramjithendra Posted in ASP.NET

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s