RedirectToAction和“对象已移至此处”错误

问题描述

| 我在MVC 3.0中遇到RedirectToAction的奇怪问题。 这是我的示例ViewModel的代码
public class EventViewModel
{
  [Required(ErrorMessageResourceType = typeof(Resources.Validations),ErrorMessageResourceName = \"Required\")]
  public DateTime CreationDate { get; set; }

  [Required(ErrorMessageResourceType = typeof(Resources.Validations),ErrorMessageResourceName = \"Required\")]
  [AllowHtml] //here is my apparent problem
  public string Description { get; set; }

  [Required(ErrorMessageResourceType = typeof(Resources.Validations),ErrorMessageResourceName = \"Required\")]
  [Range(0,5,ErrorMessageResourceType = typeof(Resources.Validations),ErrorMessageResourceName = \"RangeValue\")]
  public int Rating { get; set; }
  [Required(ErrorMessageResourceType = typeof(Resources.Validations),ErrorMessageResourceName = \"Required\")]
  public string Title{ get; set; }

  ...other properties...

}
这是我控制器的两种方法
public ActionResult Edit(int id)
{
  var entity = eventsRepository.Get(id);
  if (entity == null)
    return RedirectToAction(\"Index\");
  var eventVM = new EventViewModel();
  eventVM.Description = entity.Description;

  ... set the other properties ...

  return View(eventVM);
}

[HttpPost]
public ActionResult Edit(int id,EventViewModel model)
{
  if (ModelState.IsValid)
  {
    try
    {
      var entity = eventsRepository.Get(id);
      if (entity == null)
        return RedirectToAction(\"Index\");
      entity.CreationDate = model.CreationDate;
      entity.Description = model.Description;

      ... set the other properties ...

      eventsRepository.Save(entity);
      return RedirectToAction(\"Index\");
    }
    catch (Exception e)
    {
      ModelState.AddModelError(\"\",\"An error occured bla bla bla\");
    }
  }

  return View(model);
}
我的问题是,如果我删除
AllowHtmlAttribute
并在描述字段中插入纯文本,一切正常,并且保存后得到重定向,但是如果我将description2ѭ放在字段说明中并在保存后插入一些HTML文本,而不是重定向我得到一个只有以下文本的空白页:
Object moved to here. 
如果单击“此处”,则会重定向到正确的URL。 我是否缺少明显的东西?     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)