Questions tagged [child-actions]
33 questions
32
votes
2 answers
Does a child action share the same ViewBag with its "parents" action?
I am confused with this:
I have an action ,say Parent ,and in the corresponding view file ,I have called a child action ,say Child ,both Parent and Child actions are in the same controller.
and I need the Child action and the Parent action to share…

NextStep
- 1,035
- 3
- 14
- 18
13
votes
1 answer
How can I tell if my action is being called by RenderAction?
I have an action that could potentially be called via a normal link, in which case I'd return a View(), or it could also be called via AJAX or RenderAction (ie as a Child Action) in which case I'd return a PartialView().
Sorting out the AJAX part is…

StanK
- 4,750
- 2
- 22
- 46
6
votes
3 answers
ASP .Net MVC 3: Child Action and Redirect
I need to display the registration form and login form on the home page.
If validation fails on these two forms, I need to display proper errors on the home page.
But if there was no error, the user must be redirected to the secured Dashboard.
To…

Moon
- 33,439
- 20
- 81
- 132
5
votes
1 answer
MVC3 Why do I get "Child actions are not allowed to perform redirect actions" error?
I got an action List
//[HttpGet] (will come back to that!)
public ViewResult List(int page = 1)
{
//blah blah blah
return View(viewModel);
}
In its view we render action:
@{
…

Mariusz.W
- 1,347
- 12
- 19
4
votes
1 answer
Posting data back to ASP.NET MVC child actions
Since we can compose a single view from a main view + a partial view (e.g. using RenderAction, specifying a child controller), is it possible for input rendered by the child action to be directed to the child controller while input rendered by the…

Craig Boland
- 984
- 1
- 10
- 18
4
votes
1 answer
ASP.NET MVC3 Html.Action containing a form
I have a pod on my page that contains a form.
I have used this pod in a similar way to the following:
@Html.Action("Pod","Home")
There is some business rule checking in the Pod's HttpPost action which handles the form post. If this business rule…

Rob Stevenson-Leggett
- 35,279
- 21
- 87
- 141
4
votes
3 answers
MVC OutputCache for Child Actions: where is it stored?
I'm using OutputCache for caching an horizontal menu and a vertical menu in my app. I usually use something like this in the actions I want to be cached
[OutputCache(Duration=3600, VaryByParam="none", Location=OutputCacheLocation.Client,…

snekkke
- 441
- 1
- 5
- 15
3
votes
1 answer
Asp.Net mvc nested actions HTTPPOST
i ve got a weird problem. My view :
@{
ViewBag.Title = "Index";
}
Index
@using(Html.BeginForm()) { } @Html.Action("Index2") My Controller: public class DefaultController : Controller { // …
armless-coder
- 95
- 1
- 9
2
votes
0 answers
Pass data to child action's view
I have multiple views which call the same child action, which renders a view.
Depending on which view calls the child action, I want to display a different message in the childview. But since I don't need this view inside the child action's…

TDaver
- 7,164
- 5
- 47
- 94
2
votes
0 answers
Using Azure Redis Caching for ChildAction in MVC 5
I have successfully implemented Azure Redis Cache using the Microsoft RedisOutputCacheProvider which works as expected for general pages.
However, I can't seem to get it to work for child actions, it always use the default OutputCacheProvider.
How…

TyKonKet
- 304
- 2
- 6
- 13
2
votes
1 answer
Caching in ASP.NET MVC with uncachable forms
I'm doing donut caching with the MVCDonutCaching library.
Background to donut caching using this library:
The way it works, is you can cache a view, but exclude part of it from being cached, i.e. the "donut hole". You do this by having the…

h bob
- 3,610
- 3
- 35
- 51
2
votes
1 answer
Azure Redis Cache and MVC Child Actions
I have successfully implemented Azure Redis Cache using the Microsoft RedisOutputCacheProvider from NuGet which works as expected for general pages.
[ChildActionOnly]
[ChildActionOutputCache(CacheProfile.StaticQueryStringComponent)]
public…

Sam Gooch
- 131
- 1
- 4
2
votes
2 answers
How to pass data from child action to layout in ASP.NET MVC
I have a view which uses a layout, and also executes a child action.
The layout calls a partial which needs some data from the view's child action. Is there some way to pass the data up from the child action to it's parent view's layout?
I have…

David
- 15,750
- 22
- 90
- 150
2
votes
1 answer
Handling Errors in MVC Child Actions
My error handling collects (some manually, some automatically) the errors produced during controller execution. Then I have a partial view which renders out the error messages.
I store the error messages in ViewData (and transfer them to TempData…

TDaver
- 7,164
- 5
- 47
- 94
1
vote
1 answer
ASP.NET MVC3: 2 forms on page, submit triggers the wrong one
I have 2 forms on the same page. One is a form in a partial view which is rendered via a child action we'll call this PodForm. The second is rendered by the current action.
So my code looks a little like this (please ignore names etc, this is…

Rob Stevenson-Leggett
- 35,279
- 21
- 87
- 141