Shaun Roberts
Shaun Roberts

Reputation: 1

Visual Studio, typing a comment /* etc */ very odd behaviour in aspx files

My Visual Studio 2022 community edition is behaving unusually when entering comments inside .aspx files, that should look like this.

/*
* This is a comment
* This is another line
*
*/

I've tested doing the same thing in a .cs file and it works the way I expect. So to confirm, the unwanted behavior is only happening inside code written in between script tags of an aspx file.

<%@ Page Language="c#"%>
<script runat="server">

   Here...

<script/>

In Visual Studio 2017, when I enter a multiline comment manually, I begin typing '/*' and upon pressing return, the carriage return would automatically move to the next line down, prefixing it with a *, and if I continue pressing return, the same would happen. The same is not true with my copy of Visual Studio 2022... where instead, when I type '/*' and press return, my cursor remains flashing just to the right of the *, but the inserted carriage return is added seemingly randomly, 28 or more lines beneath where my cursor is.

Has anyone encountered this? Thanks

Upvotes: 0

Views: 49

Answers (1)

Minxin Yu - MSFT
Minxin Yu - MSFT

Reputation: 4110

<script runat="server">

   Here...

<script/>

The scrpit format is wrong.

<script/> should be </script>

In addition, if a similar statement <%@ Page Language="c#"%> already exists in the first line of aspx, the duplicate statement will cause the error.

Since code problems cause editor errors and lead to subsequent errors, please check carefully and fix the errors.

Upvotes: 0

Related Questions