473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

HTML Encoding in ASP .NET 2.0 Best Practices

I currently have a web application with hundreds of pages and controls.
There currently is no HTML Encoding done anywhere. Data to the
application come from all different places such as UI, WebServices,
Remoting and listeners that log data. All this data needs to be shown
to the user at some point and all of it can include some sort of HTML.

How in the world can I make sure that this informations is displayed
properly without allowing the HTML in the Data to mess up the HTML in
the page. Of course i have to HTML Encode the information but how do i
do that?

I have tons of pages! Do i really have to go to every possible page,
looking for every possible piece of output information and
Server.HtmlEncode it? That has to be the most painful thought i could
possibly think of :)

Maybe there is a desing principle i'm missing. Maybe if i had coded my
pages in a certain technique, all the information would have to through
certain controls, or through a certain mechanism that makes sure what
needs to be encoded is encoded and what needs to be left unencoded
remains unencoded.

Any help?

Thanks,

Mark

Feb 24 '06 #1
1 1646
well best practice would have been to think about this at the design of the
site.

1) which data fields are html that should be displayed as html and are
certified safe.
2) which data fields have html which should be scrubbed, remove scripting,
check for dangling tokens (say a <b> with no </b>), imbedded forms, etc.
3)which data is just raw data and should be displayed as the characts type
(input <hi>, should be displayed as <hi>).

all data should handling should default to #3. this means no response write
without encoding, no InnerHtml without validation. most controls will do the
correct behavior if you use the Text value.

-- bruce (sqlwork.com)

"Untitled" <ma*******@hotmail.com> wrote in message
news:11**********************@j33g2000cwa.googlegr oups.com...
I currently have a web application with hundreds of pages and controls.
There currently is no HTML Encoding done anywhere. Data to the
application come from all different places such as UI, WebServices,
Remoting and listeners that log data. All this data needs to be shown
to the user at some point and all of it can include some sort of HTML.

How in the world can I make sure that this informations is displayed
properly without allowing the HTML in the Data to mess up the HTML in
the page. Of course i have to HTML Encode the information but how do i
do that?

I have tons of pages! Do i really have to go to every possible page,
looking for every possible piece of output information and
Server.HtmlEncode it? That has to be the most painful thought i could
possibly think of :)

Maybe there is a desing principle i'm missing. Maybe if i had coded my
pages in a certain technique, all the information would have to through
certain controls, or through a certain mechanism that makes sure what
needs to be encoded is encoded and what needs to be left unencoded
remains unencoded.

Any help?

Thanks,

Mark

Feb 25 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Ron | last post by:
Hello, I'm having an aggravating time getting the "html" spewed by Word 2003 to display correctly in a webpage. The situation here is that the people creating the documents only know Word, and...
2
by: byrocat | last post by:
I'm chasing after a documetn that was available on one of the Microsoft websites that was titled somethign like "MS SQL Server Best Practices" and detailed a nyumber of best practices about...
24
by: chri_schiller | last post by:
I have a home-made website that provides a free 1100 page physics textbook. It is written in html and css. I recently added some chinese text, and since that day there are problems. The entry...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
13
by: john doe | last post by:
A quick question, about so-called 'best practices', I'm interested in which of A/B of the two examples people would choose, and why. public enum MyEnum { Option1 = 0, Option2 = 1, Option3 =...
15
by: Nathan | last post by:
I have an aspx page with a data grid, some textboxes, and an update button. This page also has one html input element with type=file (not inside the data grid and runat=server). The update...
6
by: mistral | last post by:
what encoding better to select when paste javascript or php code into windows Notepad and 'Save as'? ANSI, Unicode, Unicode big endian, UTF-8 ? m.
5
by: Timothy Madden | last post by:
Hello Is there a function that will allow me to output text written in utf-8 (from db for example) if my document has Content-Type: text/html; charset=ISO-8859-1 I mean htmlspecialchars()...
5
by: GaryDean | last post by:
Anyone know of html screen scrapper software that will work with .net projects. We need to get data back from a gov site that only provides it on a webpage. Thanks, Gary
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.