开发者

How to debug RedirectToAction

I am trying to debug a problem wherein RedirectToAction appears to be working properly (i.e., the redirected-to Action is executed) but the specified View is never rendered on the client side and the url is not rewritten. My question is really where can I be looking to debug this? Here's the code:

Form:

<%using (Html.BeginForm("Save", "Items", FormMethod.Post, new {id="ItemForm"})) {%>
  <%=Html.AntiForgeryToken()%>
   ..form contents elided...
       <%= Html.Button("btnSave", ViewData.Model.SaveMethod, HtmlButtonType.Submit) %>
       <%= Html.Button("btnCancel", "Cancel", HtmlButtonType.Button, 
                                "window.location.href = '" +      Html.BuildUrlFromExpressionForAreas<ItemsController>(c => c.Index()) + "';") %>     
<% } %>

Controller:

    [ValidateAntiForgeryToken]
    [Transaction]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Save(Item item)
    {
        if (item.Id == Guid.Empty)
            return Create(item);

        return Edit(item);
    }

    [ValidateAntiForgeryToken]
    [Transaction]
    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Edit(Item item)
    {
        if (ViewData.ModelState.IsValid)
        {
            ActionConfirmation updateConf开发者_开发知识库irmation =
                _itemManagementService.UpdateWith(item, item.Id);

            if (updateConfirmation.WasSuccessful)
            {
                TempData[ControllerEnums.GlobalViewDataProperty.PageMessage.ToString()] =
                    updateConfirmation.Message;
                return RedirectToAction("Index");
            }
        }

        ItemFormViewModel viewModel =
            _itemManagementService.CreateFormViewModelFor(item, _indicatorManagementService, _strategyManagementService);
        return View(viewModel);
    }

    [Transaction]
    public ActionResult Index()
    {
        ItemsFormViewModel viewModel = _itemManagementService.CreateListFormViewModel(_indicatorManagementService,
                                                                                      _strategyManagementService);
        return View(viewModel);
    }

I am using a custom model binder, but model.IsValid returns true and the changes to the model save successfully. I am at a loss as to where to look to track this down.

Thanks for looking.


As always, as soon as I post, I finally figure it out. Had some left over jquery from a previous approach that was hijacking the submit.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜