I'm a professional writer and software developer with more than 10 years of experience. I have worked for a lot of businesses and can share sample works with you upon request. Chat me up and let's get started.....
Into the ChildAction methods will not be responded to incoming URL requests. If you try to invoke the childActions using URL, then you will get a runtime error saying – ChildAction is accessible only by a child request.
We can only access the child action methods by making a child request from a view either by using the “Action()” or “RenderAction()” HTML helper methods.
Here, the most important point that you need to remember is, an action method doesn’t need to have the ChildActionOnly attribute to be used as a ChildAction. We need to use this ChildActionOnly attribute only if you want to prevent the action method to be invoked using URL.
The ChildAction methods are different from the NonAction methods in the MVC application. Here, the difference is that the NonAction methods cannot be invoked as a child request either by using the Action() or RenderAction() HTML helpers.
The main advantage of the Child Action method is that you can cache portions of a view. We will discuss this in the OutputCache Attribute article.
Liked By
Write Answer
What is ChildActionOnly Attribute in MVC ?
Join MindStick Community
You have need login or register for voting of answers or question.
Rahul Roi
28-Oct-2020ChildActionOnly Attribute in MVC