Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. HtmlEncode & Db field length

HtmlEncode & Db field length

Scheduled Pinned Locked Moved ASP.NET
databasesecurityhelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blumen
    wrote on last edited by
    #1

    Hi, I read in an MSDN article that we have to encode user input using HtmlEncode for security reasons. I used to do this many projects, but recently I encountered an issue. When the text is encoded it sometimes becomes huge that it exceeds the field length in database and db throws exception. This is normal I suppose, is giving more length to db fields only solution for this? Regards, Blumen

    “The thing for you is a burial permit. You have only to speak and I will see that you get it.”

    A 1 Reply Last reply
    0
    • B Blumen

      Hi, I read in an MSDN article that we have to encode user input using HtmlEncode for security reasons. I used to do this many projects, but recently I encountered an issue. When the text is encoded it sometimes becomes huge that it exceeds the field length in database and db throws exception. This is normal I suppose, is giving more length to db fields only solution for this? Regards, Blumen

      “The thing for you is a burial permit. You have only to speak and I will see that you get it.”

      A Offline
      A Offline
      Abhishek Sur
      wrote on last edited by
      #2

      Generally we do HTMLEncode when you need to disable javascripts to be running on the browser when it is shown in the web page. I would suggest you to HTMLEncode before showing on the page rather than doing it while storing data into the database. Why do you need to store the encoded string on the database.

      Abhishek Sur

      B 1 Reply Last reply
      0
      • A Abhishek Sur

        Generally we do HTMLEncode when you need to disable javascripts to be running on the browser when it is shown in the web page. I would suggest you to HTMLEncode before showing on the page rather than doing it while storing data into the database. Why do you need to store the encoded string on the database.

        Abhishek Sur

        B Offline
        B Offline
        Blumen
        wrote on last edited by
        #3

        I encode data from Textboxes before saving them in database

        “The thing for you is a burial permit. You have only to speak and I will see that you get it.”

        A 1 Reply Last reply
        0
        • B Blumen

          I encode data from Textboxes before saving them in database

          “The thing for you is a burial permit. You have only to speak and I will see that you get it.”

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          Dont Encode before saving them in database. Rather, you should encode after you fetch from the database.

          Abhishek Sur

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups