I changed the Get clause using:
<a style="text-decoration:none;" href="@Url.Action(item.ListAction, item.ListController, new { ids = string.Join("-", item.Ids), categoryId = item.Id, search = (string)ViewBag.Search, location = (string)ViewBag.Location })">
To:
@using(Html.BeginForm(null, null, FormMethod.Post, new { id = "homeCategoryForm" })) { @Html.AntiForgeryToken() @Html.Hidden("ids") @Html.Hidden("categoryId") @Html.Hidden("search") @Html.Hidden("location") }
Transmission using jQuery:
$(document).on("click", ".innerelement", function (e) { var elementId = e.target.id.split('_')[1]; action = "/" + $("#controller_" + elementId).val() + "/" + $("#action_" + elementId).val(); $("#homeCategoryForm").attr("action", action); $("#ids").val($("#ids_" + elementId).val()); $("#categoryId").val($("#categoryId_" + elementId).val()); $("#search").val($("#search_" + elementId).val()); $("#location").val($("#location_" + elementId).val()); $("#homeCategoryForm").submit(); });
Controller:
[HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public virtual ActionResult GetAllByIds(string ids, int categoryId, string search, string location) { AdGetAllByCategoryListViewModel model = new AdGetAllByCategoryListViewModel(); model.Ads = Mapper.Map<IList<AdGetAllByCategoryDto>, IList<AdGetAllByCategoryViewModel>>(_adService.GetAllByIds(ids)); model.Category = Mapper.Map<CategoryDto, CategoryViewModel>(_categoryService.GetById(categoryId)); return View(MVC.Ad.Views.GetAllByCategory, model); }
The problem is that View using the Form Post method creates the / json View (Source) application, not the / html text.
EDIT:
The view is a render from PartialView, so maybe this is a problem?
I tested with PartialView, and the HTML representation is rendered, but not all kinds of layout.
Any idea why?
thanks