Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I got bitten by something similar in (someone else's!) JSP last week. The HTML comments don't stop the tag from being parsed; if it generates an HTML comment, you end up with nested HTML comments and all manner of strange things going on.</p> <p>The only "safe" use of HTML-style comment delimiters in an ASP/JSP is where there is no generated content between them:</p> <pre><code>&lt;!-- This is safe --&gt; </code></pre> <p>We know exactly what that will be after the ASP engine has parsed it - it'll look the same. The problem <strong>may</strong> bite you when you have an ASP tag in there:</p> <pre><code>&lt;!-- This might not be safe because I have no idea what &lt;asp:joesCustomTag/&gt; expands to --&gt; </code></pre> <p>If that tag generates an HTML comment, you'll have an HTML comment in your HTML comment! Let's see what happens when that custom tag is parsed and the HTML gets sent to the browser:</p> <pre><code>&lt;!-- This might not be safe because I have no idea what &lt;!-- Joe's custom tag --&gt; &lt;p&gt;Joe is 1337&lt;/p&gt; expands to --&gt; </code></pre> <p>You can see the problem right there - SO's own parser is confused by the nested comments. <strong>It's safest to assume that every tag generates an HTML comment, and that putting it in an HTML comment will bite you.</strong> Even if it's your tag, you might add an HTML comment to it later.</p> <p>The answer, as Paperjam says, is to use the correct server-side comments to comment things out - though, of course, you really shouldn't be leaving commented-out dead things around waiting to bite you. Only use HTML-style comments if you actually want a comment to appear in the HTML source.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload