我正在尝试调试一个问题,其中RedirectToAction似乎工作正常(即,重定向到的操作被执行),但指定的视图永远不会在客户端呈现,url也不会重写。我的问题是,我可以在哪里调试它?代码如下:
表格:
<%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,并且成功保存了对模型的更改。我不知所措,不知道在哪里可以找到它。
谢谢你的关注。
发布于 2010-07-17 00:47:23
一如既往,我一发帖,我就终于想明白了。之前劫持提交的方法留下了一些jquery。
https://stackoverflow.com/questions/3267044
复制相似问题