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

  • Home
  • SEARCH
  • 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 9005337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:07:03+00:00 2026-06-16T01:07:03+00:00

I’ve got a typical C# automatic property. How can I apply WebUtility.HtmlDecode() when I’ve

  • 0

I’ve got a typical C# automatic property. How can I apply WebUtility.HtmlDecode() when I’ve only got a get; set;?

UPDATE:

Ok, dumb mistake of the day. I had a weird issue where my web.config db connection string was pointed to the right server but for some reason since I had 2 instances (one sql 2008 and 2012) it was still picking up the instance of that DB in 2008 which had the encoding still there. I had fixed the encoding issue by just decoding the Title via a unit test I created in the 2012 DB which in this case this whole fing post was unecessary in stack because the ultimate problem was it was reading from the old DB (messing me up).

Anyway I had already fixed this, finally got rid of the 2008 copy and now it’s reading it fine after my fix:

  [Test]
    public void CleanAllPostEntries_DecodeHTML_DecodeWasSuccessful()
    {
        // Arrange

        // Act
        IEnumerable<Entry> posts = PostCRUD.GetAllPosts();

        foreach (Entry post in posts)
        {
            post.Title = WebUtility.HtmlDecode(post.Title);
            post.Body = WebUtility.HtmlDecode(post.Body);
            post.MetaTitle = WebUtility.HtmlDecode(post.MetaTitle);

            PostCRUD.UpdatePost(post);

            //System.Diagnostics.Debug.WriteLine("id: " + post.Id);
            //System.Diagnostics.Debug.WriteLine("title: " + WebUtility.HtmlDecode(post.Title));
            //System.Diagnostics.Debug.WriteLine("body: " + WebUtility.HtmlDecode(post.Body));
        }

        //Assert
        // TODO: add asserts
    }    

So I don’t think I need the decode afterall..I already did it!

  • 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-06-16T01:07:04+00:00Added an answer on June 16, 2026 at 1:07 am

    You really don’t want to do HTML encoding/decoding via properties, although you could if you wanted to. There are several problems with this:

    1. You’ll be taking that encoding/decoding hit on every single access of the property, be it reading or writing.
    2. The HTML encode/decode is a “lossy” conversion and you only want to do it exactly once per string; you don’t want to be constantly encoding and decoding and re-encoding the same string when you’re tossing it around on multiple properties, you’ll start to lose information that way.
    3. The HTML encoding of the content is not a property of the object you’re storing it with, it is a property of the content itself.

    What you really want to do is use a stronger type that represents the HTML-encoded string.

    The .NET 4.0 framework includes a System.Web.HtmlString type which you should use for this purpose. In fact, use the System.Web.IHtmlString interface if you wish to remain general.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
Does anyone know how can I replace this 2 symbol below from the string
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all

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.