asp.net remove white space in html

A

Aaron

is there a way to remove all white spaces in the html output? ie. everything
as one line.
 
C

Craig Deelsnyder

Aaron said:
is there a way to remove all white spaces in the html output? ie. everything
as one line.

Well, Response.Filter is where I'd start:

http://msdn.microsoft.com/library/d...rlrfSystemWebHttpResponseClassFilterTopic.asp

But I don't know eliminating all whitespace is what you'd do, cuz you'd
have to figure out how to detect if you were inside of a tag (don't want
to just erase all spaces, etc.). You wouldn't strip out whitespace like
that.

But you could strip out things like Tab characters (if this is what you
meant). crlf's I thought were problematic when I tried it for a client
(for their pages), but I can't think of why (I thought it caused
problems in Javascript. As long as every line ends with ; the JS should
still run fine. Unless you use the <!-- // --> wrapper around
scripts, as I don't think this can go all on the same line. Example:

<script language="javascript">
<!--
alert('hello');
// -->
</script>
 
K

Kevin Spencer

It sounds like he only wants to filter out line breaks, for whatever reason.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.
 
Joined
Aug 22, 2009
Messages
2
Reaction score
0
Remove unnecessary white spaces and line breaks from ASP.NET page

This article provides details about how to remove unnecessary line breaks and white spaces from ASP.NET when it is rendered to the browser:

altafkhatri.com/Altaf/Remove_Unnecessary_Space_And_Line_Break_From_MVC/Html_Remove_Line_break_ASP_NET/MVC_Remove_Line_break_Spaces
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top