Reputation: 3451
How can I do a POST and RedirectToUmbracoPage()
with a custom model. As far as I can tell, RedirectToUmbracoPage
takes a nodeId, but I couldn't tell how to pass it my custom model. The model I have does inherit from RenderModel
, but I am getting the error that my view expects my custom model, but it was passed a RenderModel.
Initially, I was just returning View("page")
, but this causes another post on refresh, so what I would really like to do is redirect the user? Also, I am not sure if a POST
is what I need because I am basically searching a database and returning results, I am actually not saving any data, but I am not sure how to do what I want with a GET
?
In a nutshell, I want to search a database with some Form values, get the data into a model and redirect the user to another page with my model?
Below works without a custom model, now it is just a matter of getting that in there.
var nodeId = Convert.ToInt32(CurrentPage.GetProperty("NoProductsFoundUrl").DataValue);
return RedirectToUmbracoPage(nodeId);
Upvotes: 2
Views: 1522
Reputation: 5917
I recommend you use a ChildAction
for this:
@Html.Action("DoSearch", "Search")
- calling the action DoSearch
on the SearchController
DoSearch
method, decorated with [ChildActionOnly]
(this attribute is not required but it stops people from using the method in any other way than @Html.Action
return PartialView("~/Views/Partials/SearchPartial.cshtml", model);
@model My.Custom.SearchModel
Upvotes: 0