I have an ASP.NET MVC3 site where I need to show some account-related stats in the sidebar
I have a RenderAction in the layout i.e.
@{ Html.RenderAction("GetStats", "MyController"); }
and the action method in MyController returns some text
[HttpGet]
public ContentResult GetStats()
{
... snip (get stats from cache/db as the case may be)....
return Content(String.Format("Your stats: {0}", stats));
}
which works fine under normal circumstances.
However, say the view contains a form, and if a server-side model validation error is thrown, then the the render action returns a 404 view embedded where the stats should be. The rest of the page shows up fine, with the correct validation message etc.
I also tried using a regular partial view instead of a ContentResult with the same results.