Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3457118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:49:18+00:00 2026-05-18T09:49:18+00:00

I have a comment model with string property like this: [Column] public string Text

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:49:18+00:00Added an answer on May 18, 2026 at 9:49 am

    What you have to do is turn off validation for that particular input field. To do that you can add this filter to you action:

    [ValidateInput(false)]
    

    Or if you want to be specific and only turn it off on that one field (maybe it will work on multiple, i haven’t tested that though) do something like this:

    [ValidateInput(true, Exclude = "YourFieldName")]
    

    This will exclude you field but still check all other fields.

    ADDON: Adding filters ca be done in (AFAIK) two way. Here are 2 samples:

    [HttpPost, ValidateInput(true, Exclude = "YourFieldName")]
    public ActionResult SomeAction(...) { ... }
    
    [HttpPost]
    [ValidateInput(true, Exclude = "YourFieldName")]
    publiv ActionResult SomeAction(...) { ... }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have article model with public ICollection<Comment> Comments { get; set; } and comment
I have a data model where a User can like a Project, Suggestion, Comment
I've got a model: public class OverdraftForm { public string CustomerId { get; set;
I have this link @Ajax.ActionLink(comment, CreateDebateComment, new { id = Model.DebateID}, new AjaxOptions {
So, say I have models like this: class Foo(Model): name = CharField(max_length=200) def latest_comment(self):
I have a partial class in a dbml file. public partial class Comment string
I have a simple one-to-many structure like this: class User(db.Model): userEmail = db.StringProperty() class
I have a string containing a set of ActiveRecord models and I would like
I have a view model public class UserRegister { [Remote(CheckUserEmail)] public string Email {
I have a Comment model in my app but am encountering a lot of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.