0

In my page source I put: <!-- A comment -------->

and ASP.Net converts it to: &lt;!-- A comment --------&gt;

so by the time it gets to the browser, my comment is visible.

It doesn't do it to all comments and if I add in another comment it sometimes makes the comment go away.

Anyone seen this before? How can I fix it?

3 Answers 3

2

Try putting an space before -->. It guess this might help. I haven't had such a problem before though.

It's a good practice:

  • not to have -- in comments
  • begin your comments with <!-- without more dashes
  • end your comments with --> without more dashes
Sign up to request clarification or add additional context in comments.

4 Comments

That does seem to help & I take the point about best practice and will follow that more carefully from now on but quite what ASP.Net is thinking of when deliberately converting the comments I don't know!
ASP.NET parser does care about HTML. It parses it on the server to some level. This is how it handles runat="server" tags.
Yep, I get that I guess I expected it to just ignore anything it doesn't understand. Global search and relace here I come. Thanks for the response.
It's not just a matter of best practice: getting the wrong number of -- tokens in HTML as above (or in XML, using any -- other than -->) is invalid and can cause parsers (and even sometimes browsers) to choke. Avoid.
1

Please check this page about comments and see if it helps.

Comments

0

Response.Write("<!--");

rest of html?

Resonse.Write("-->");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.