I have a control on my master page that I create using RenderAction. The problem I'm having is when I use a form somewhere else on the page it renders this action using HttpPost instead of HttpGet.
I get why it's doing this as the request is a post, however this is not the desired or expected result as the control was not in anyway involved in the user action.
Simplified example:
<div id="search-panel">
<% Html.RenderAction("Index", "TestController"); %>
</div>
<% using (Html.BeginForm("Update", "Products")
{%>
<%: Html.Hidden("productId", Model.ProductId) %>
<%: Html.TextBoxFor(model => Model.Name)%>
<input type="submit" vaue="Submit"/>
<% }%>
When the user submits the Update Products form the form in Index TestController is also rendered as if it was submitted. This makes the RenderAction
for controls somewhat useless.
Any idea's on workarounds or better approaches would be most welcome.
Cheers
UPDATE
I do not wish to use RenderPartial as suggested for the following reason. The control in this case is a search box with many options populated from a database. The logic for this control/view should be in the SearchController.
The main area of the page may contain views form other controllers, e.g. a product view. To use RenderPartial, the ProductController would have to create view data for the search box. This is not it's job, the ProductController has no business knowing the Search functionality even exists.
I have found a solution using this blog post. It also explains the problem I'm having well. It seems odd that MVC is missing this functionality.