Note that there are some explanatory texts on larger screens.

plurals
  1. POwith MVC 4.0, RedirectToAction does not render PartialView as Partial, it send a whole page
    primarykey
    data
    text
    <p>I got something a little complicated, but I don't see why it would not work: I have a JSTree in my Index.cshtml. When a node is selected, I make an Ajax call to </p> <pre><code>public async Task&lt;ActionResult&gt; GetEBooksItems(string id) </code></pre> <p>which return a partial view. This works PERFECTLY WELL.</p> <p>Now, in addition to the tree search, I have a form to add some criterias to narrow down the search. I use Ajax.BeginForm to Post data back to the controller.</p> <pre><code> public async Task&lt;ActionResult&gt; GetEBooksCustom(GenericSearchViewModel filter) { vm = filter; //Session["GenreNodeId"] = id; Session["SearchCondition"] = (string.IsNullOrEmpty(vm.Condition) != true) ? vm.Condition : "All"; Session["MaximumPrice"] = (string.IsNullOrEmpty(vm.MaxPrice) != true) ? vm.MaxPrice : "999999"; Session["MinimumPrice"] = (string.IsNullOrEmpty(vm.MinPrice) != true) ? vm.MinPrice : "0"; Session["SearchIndex"] = (string.IsNullOrEmpty(vm.SearchIndex) != true) ? vm.SearchIndex : "KindleStore"; Session["SortOrder"] = (string.IsNullOrEmpty(vm.SortOrder) != true) ? vm.SortOrder : "price"; Session["KeyWords"] = (string.IsNullOrEmpty(vm.Keywords) != true) ? vm.Keywords : ""; Session["Title"] = (string.IsNullOrEmpty(vm.Title) != true) ? vm.Title : ""; Session["Author"] = (string.IsNullOrEmpty(vm.Author) != true) ? vm.Author : ""; return RedirectToAction("GetEBooksItems", new { id = vm.CategoryNodeId }); } </code></pre> <p>to this method, wich in turn call the first one with a RedirectToAction. </p> <p>I have been trying everything I could think of, I always get the results as a whole page, instead of a Partial view, like in the first method.</p> <p>It looks like the call to GetEBooksCustom is not "seen" as an Ajax call. What do I miss? Thanks for your help, Bernard.</p> <p><em><strong></em>**<em>*</em>*</strong><em>Edit 6 hours later</em><strong><em>*</em>**<em>*</em>**<em>*</em>**<em>*</em></strong></p> <p>In between i did what was suggested, that is to extract the functionalities from "GetEBooksItems", to be able to directly return a PartialView instead of using RedirectToAction. In the debugger, it looks like everything is perfect, I see a 200 answer from the server, BUT I still get a full page display, and the url display the controller method, while this should not be the case for an ajax call.</p> <p>The thing is, I have basically the same form somewhere else, where it works as expected. Can't see what could be different???</p> <p>As always, thanks for your help and suggestions. Bernard</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload