Having a view post back to itself with a different view. Am I doing it correctly?
OK,
So I am doing something that doesn't feel right, but I am not sure what my options are or what are the better ways. This is an high level overview at first so you can see what I am trying to achieve:
In my backoffice, I have the following structure:
Home
Products
Product
When the user goes to the /products page, they form to search for products first, so what I did was put this search form in a partial view called ProductFilter.cshtml in my views\partials\ folder. When the user clicks submit, I have another view SearchResults.cshtml that is located in views\ProductFilter\.
In my ProductFilterController, I have the following code which passes the model to the SearchResults view, however, since SearchResults is not a template in Umbraco, the /products page gets posted with the search results, which works, but I am not sure if this is a good thing to do. Also, when the user clicks the browser refresh, it posts again.
[HttpPost]
public ActionResult SearchResults(ProductFilterModel productFilterModel)
{
var db = new Database("productsDb");
var productSearchResultsModel = new ProductSearchResultsModel
{
ProductFilterModel = productFilterModel,
Products = db.Fetch<ProductViewModel>(@"SELECT *
FROM Products")
};
return View(productSearchResultsModel);
}
Having a view post back to itself with a different view. Am I doing it correctly?
OK,
So I am doing something that doesn't feel right, but I am not sure what my options are or what are the better ways. This is an high level overview at first so you can see what I am trying to achieve:
In my backoffice, I have the following structure:
When the user goes to the
/products
page, they form to search for products first, so what I did was put this search form in a partial view calledProductFilter.cshtml
in myviews\partials\
folder. When the user clicks submit, I have another viewSearchResults.cshtml
that is located inviews\ProductFilter\
.In my
ProductFilterController
, I have the following code which passes the model to theSearchResults
view, however, sinceSearchResults
is not a template in Umbraco, the/products
page gets posted with the search results, which works, but I am not sure if this is a good thing to do. Also, when the user clicks the browser refresh, it posts again.Thanks, Saied
is working on a reply...