I have a comment model with string property like this:
[Column]
public string Text { get; set; }
Comment text can have all HTML tags inside (i know it's bad, but i have to). But when i update object, MVC 2 escapes all HTML tags.
Updating method is:
[HttpPost]
public ActionResult Edit(int ID=0)
{
Comment comment= ID == 0
? new Comment ()
: commentRepository.Comments.First(x => x.ID == ID);
TryUpdateModel(comment);
if (ModelState.IsValid)
{
commentRepository.Save(comment);
return RedirectToAction("View/" + comment.ID);
}
else
{
return View(comment);
}
}
How can i update comment text without escaping?
P.S. Also i have problem with column type: when i switch column Text in SQL Server Express from varchar to text, updating model fails:
The data types text and nvarchar are incompatible in the equal to operator.
Exception Details: System.Data.SqlClient.SqlException: The data types text and nvarchar are incompatible in the equal to operator.