2010-07-16 22 views
1

我想調試一個問題,其中RedirectToAction似乎正常工作(即重定向到Action被執行),但指定的View永遠不會呈現在客戶端,並且URL不會被重寫。我的問題真的在哪裏可以調試呢?下面的代碼:如何調試RedirectToAction

形式:

<%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()) + "';") %>  
<% } %> 

控制器:

[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 updateConfirmation = 
       _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); 
    } 

我使用的是自定義的模型綁定,但model.IsValid返回true並且改變模型成功保存。我無法確定在哪裏尋找這些信息。

感謝您的期待。

回答

0

一如既往,只要我發佈,我終於搞清楚了。由於以前的方法劫持了提交,有一些人遺留了jquery。