This extension is a port of the HTML (C#) extension for Sublime Text. It provides syntax highlighting for HTML files with embedded C#, such as .aspx
, .cshtml
, and .master
.
Embedded C# (<script runat="server">
)
runat="server"
must immediately follow the tag opening.Comment blocks (<%-- foo --%>
)
The Response.Write
expressions (<%=
, <%#
, <%:
, <%$
)
Toggle comment (Ctrl+/ or Cmd+/)
Snippets for <%
expressions (Try typing e=
.)
Snippets for some directives (Try page
or import
.)
text.html.basic
. (This is standard in VS Code. Unless you have disabled it, you are fine.)Blocks of <% %>
are not highlighted. They should not interfere with other sections of code. Highlighting would work for self-contained blocks, but not for blocks containing unclosed braces (<% if (condition) { %>
). Since those blocks are potentially destructive to highlighting for the rest of the file, the C# syntax is not injected into those contexts. It is impossible to determine whether a certain block contains unbalanced braces when deciding whether to inject the C# syntax.
This behavior stems from VS Code issue #20488 wherein the syntax engine eagerly expects a closing brace that does not appear until after the %>
. You can observe the same issue in the HTML syntax. Open a new VS Code tab, set it to the HTML syntax, and add this content:
<style>
h1 {
</style>
<p>Still in CSS mode</p>
Unless you use a custom icon theme, files highlighted by this package will use the Plain Text icon. VS Code issue #14662 would allow package authors to designate icons for their packages without releasing a comprehensive icon theme.
Because <%=
and other constructs share the same closing sequence (%>
) as <%
has, when your cursor is on the closing sequence, the opening sequence will only mark the <%
part, even if the next character is also part of the expression.
See the change log.
runat="server"
asp
-namespaced tags.