0

詳細なデータ検証を使用したい。[AllowHtml]属性が で機能しませんFormCollection。を使用する以外の方法はありますValidateInput(false)か?

メタデータ:

[AllowHtml]
[DataType(DataType.MultilineText)]
[Display(Name = "Content")]
public string Content { get; set; }

in edit action:

[HttpPost]
public virtual ActionResult Edit(int id, FormCollection formCollection)
{
    var obj = service.Get(id);

    if (ModelState.IsValid)
    {
        UpdateModel(obj, formCollection);
        service.Update(obj);

        return OnEdited(obj);
    }

    return View(obj);
}
4

2 に答える 2

0
[HttpPost]
public virtual ActionResult Edit(T obj)
{
    if (ModelState.IsValid)
    {
        if (TryUpdateModel(obj))
        {
            T old = service.Get(obj.ID);
            UpdateModel(old);
            service.Update(old); // EntityModelObject.SaveChanges();

            return OnEdited(obj);
        }
    }

    return View(obj);
}
于 2013-04-19T22:38:52.953 に答える