
HTML comments waste bandwidth. We can instead use server-side comments. We can comment .aspx files with ASPX comments—this restricts the debugging information and comments to the development environment, improving efficiency.
This page looks at examples of ASP.NET comment syntax. Server-side comments are removed before the page is sent.
Here I introduce ASP.NET server-side comments. Not only that, but I offer some uses that are not widespread but can make your site stand out from its competitors. First, let's look at a couple comments in an .aspx file.
HTML comment example
<!-- HTML comment
Will bloat every page sent to browsers
Makes your site super-slow. -->
Text
ASPX comment example
<%-- ASPX comments
Uses percent sign
Removed at compile time
Doesn't increase size of markup
You can even optimize with them. --%>
TextOutput. As you know, each .aspx page is compiled into a control tree. As this happens, ASP.NET removes server-side comments (such as the second one above, which uses %). When the browser receives the page, the markup would look like this:
Result of above two examples
<!-- HTML comment
Will bloat every page sent to browsers
Makes your site super-slow. -->
Text
TextServer-side comment removed. The second comment above was removed, and if one of your visitors downloads the page, only the HTML comment will come through the wire.

I observed something else interesting with server-side comments. They can make your web page smaller, but they can also speed up server-side processing. This is because ASP.NET constructs a control tree for each page. You can remove whitespace, which would be turned into Literal controls.
Fastest comments. When applying server-side comments, I reduced the number of Literal controls on every page by at least 10. These comments therefore improved the site's performance for every user, made the pages smaller, and reduced the complexity of the control tree on the server.

We looked at how you can use server-side comments in ASP.NET webpage markup, which is found in ASPX files mainly. We noted how the server-side comments are removed during processing and do not show up in the client-side pages. Finally, we noted some performance details and uses of server-side webpage comments.
ASP.NET Tutorials