For several days, I just can’t find a problem that really drives me crazy.
I have an asp.net (mvc4) web application where there are several index pages (list), when I click on any item in the list, it returns the edit viewing page. On the edit page (in the view itself) there is a submit button that should update db and redirect to the index page.
(Firstly, this “submit” was loaded with all the html editing code through a partial view, but I changed it so that I could redirect to the index page because “child actions are not allowed to perform redirect actions”).
So the problem is that the controller is not redirecting to the index page.
When I put a breakpoint in the post function in the controller, I see that several threads are running the code, although threads are not being requested, and if I stand with the cursor on one of the processes, then the arrows are debugging, I can see the message "process or thread changed from last step. "
Somehow I don’t know how, I solved the problem on one page (I don’t know how, because I don’t know what caused it), but sometimes (by accident) it appears again, and on another page I can’t solve it.
Here is the code from the controller and from the view:
Controller:
[HttpPost] public ActionResult Edit([ModelBinder(typeof(OpportunityBinder))] OpportunityModel draft) { try { if (Request.Params["cancel"] != null) { return RedirectToAction("index", Utils.CrmDB.GetOpportunities()); } if (draft.IsValid()) { if (Utils.CrmDB.UpdateOpportunity(draft)) return RedirectToAction("Index", Utils.CrmDB.GetOpportunities()); } return View(draft); } catch { return View(); } }
View:
@using (Html.BeginForm()) { @Html.AntiForgeryToken() @Html.ValidationSummary(true) <fieldset> /* Some divs */ <p> <input type="submit" value="Update" /> </p> </fieldset> <fieldset> /* Some partial views*/ /* loaded using @Html.Action() */ </fieldset> } @section Scripts { @Scripts.Render("~/bundles/jqueryval") @Scripts.Render("~/bundles/modernizr") @Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryui") }
Partial View Code:
@model Genius_crm.Models.ActivityListModel <p> <button id="dlgAddActivity"> New </button> </p> <div> <table> /* some tr and td */ </table> </div> <script type="text/javascript"> $(document).ready(function () { $('#dlgAddActivity').each(function () { var $link = $(this); var pathname = window.location.pathname; var parts = pathname.split('/') var sub = parts[3] var $dialog = $('<div id="addDialog"></div>') .load('@Url.Action("AddActivityToOppPartial", "Opportunity") ?CustId=@ViewBag.CustId & OppId=@ViewBag.OppId ') .dialog({ autoOpen: false, title: $link.attr('title'), width: 758, height: 265, resizable: false,
So - I hope that I have made my problem clear. I went through some posts on this issue, and none of them helped me. The problem occurs in both chrome and IE.
EDIT # 1 - When commenting on partial views, the problem disappears on all pages!
EDIT No. 2 - It seems that the problem is with the buttons loaded in the parts that use other controller actions.
EDIT # 3 - I added partial view code uploaded using @ Html.Action (), which includes one script dialog for jquery-ui.