Specific application of the attribute [ChildActionOnly]

4

I saw through the ASP.NET MVC documentation that using the [ChildActionOnly] attribute prevents the method from being called directly via GET, only through a specific view. Frankly, I did not get it. Can anyone clarify?

Example usage:

[ChildActionOnly]
public ActionResult Resultado()
    
asked by anonymous 28.02.2014 / 19:00

1 answer

4

I removed the documentation from this section here:

  

Any method marked with ChildActionOnlyAttribute can be   called only through Action or RenderAction HTML extensions   methods.

That is, if you have content that must be part of a main View, usually PartialViews .

In what scenarios could this be useful?

For example, when you build a template where parts of your site are split into PartialViews , such as _top.cshtml, _bottom.cshtml with actions Top() and Bottom() , it might be of interest to prevent them from appearing directly in the browser. from url: site.com.br/home/top

    
28.02.2014 / 19:21