@Blog.Author(Nandip Makwana) .LearningExperience(ASP.NET, ASP.NET MVC, IIS, jQuery & Technology Surrounding it...)

November 10, 2012 comment

ASP.NET MVC: ChildActionOnly action filter

ASP.NET MVC: ChildActionOnly

ChildActionOnly action filter confirms that specified action method should be only accessible by child request. Unlike NonAction filter, such methods are still treated as action method but it can’t be invoke as a parent request. More specific user can’t invoke it direct by requesting action name but we developer can invoke it through code.

Attribute Usage: Controller & method

Sample Code:

public ActionResult About()
    return View();

We can also apply this action filter at controller level so all action method of specified controller will be accessible by only child request.

What is child request in ASP.NET MVC?

So now next question arise is what is child request? So child request means we can’t access it by direct url in other word we can’t use it to begin new request/response pipeline but we can use it as action method from within code where request/response pipeline are already initiated by some other request or action method. We can use such child action method as follow.


If we try to access such method with direct url then it will throw an System.InvalidOperationException.

Check out ASP.NET MVC: Action filter series post to read about other available action filters.

You can follow me on twitter for latest link and update on ASP.NET & MVC.

comments powered by Disqus

Featured Content

Resources & Tools

About Nandip Makwana

Nandip Makwana is passionate about digital world and web. He completed his Masters in Computer Application in June 2011. Currently he is working as a Software Engineer. He has shown great promise and command over ASP.NET and technologies surrounding it during his academic years and professorial life...continue reading