I think i have identified a bug in the way ASP handles IE conditional comments (or html comments in general)..
In theory it should not handle them at all since they are meant for the client-side..
In practice ..
<!--[if IE 6]>
<!--include virtual="emptyfile.asp"-->
<![endif]-->
will return
<![endif]>
Yes, you read that correctly.. it will remove the opening of the comment include whatever is in the file and keep the closing comment tag..
This of’course will mess up the html and of’course make whatever was for the IE to be executed for all…
there are obvious workaround such as using server.execute to include your file instead of the include directive, which will work as expected..
Most likely it confuses the ending --> of the include directive with the opening <!-- of the html comment.. But it should not bother with html comments at all..
Is there a know reason this happens in this way ? or is it just a bug ?
This is not a bug.
The asp include syntax expects to find the keyword
#includein a markup comment. However it does not require that there only be white space from the end of the comment start sequence until the#includekeyword. Hence this is quite legal:-This is also legal:-
Now any subsequent occurence of the
<!--inside a comment is treated just like any other text. Hence this is still legal:-Its the first
<!--which begins the comment which is seen as an include marker by ASP. The second is just ignored text. The whole comment is replaced by the contents of the “myinc.asp” file. If the file happens to be empty then the comment is simply deleted.Now the extra
[if IE 6]>is still just ignored text so the whole of[if IE 6>\r\n<!--will be ignored text. Thus:-Is replaced by the contents of “emptyfile.asp”. Any subsequent:-
Is sent verbatim.