Invalid ASP.NET element name StartTag error

For some reason, I get this error when I try to check the code page on my computer.

Perhaps this is due to the incorrect installation of IIS, but I can not understand what the problem is.

I get the following error:

error on line 1 at column 2: StartTag: invalid element name

Here is my Default.aspx:

<%@ Page Language="C#" %>

<html>

<head>

<title>Plating Trees</title>

<script runat="server">
 protected void Page_Load(Object Source, EventArgs E)
 {

/* Begin C# Code!*/

Tree tree1 = new Tree();

tree1.Grow(3);

tree1.Message();

 }

</script>

</head>

<body>

<p><asp:label runat="server" id="Output" /></p>

</body>

</html>

Tree.cs:

/* A simple C# class! */

public class Tree
{

    public int height = 0;

    public void Grow(int h)
    {
        height += h;
    }

    public string Message()
    {
        Output.Text = "The height of tree1 is:<br/>" + tree1.height + feet";
    }

}
+3
source share
4 answers

Not sure if this is the cause of your problem, but double quotes around your attributes and code look invalid.

<script runat="server">
<p><asp:label runat="server" id="Output" /></p>

it should be:

<script runat="server">
<p><asp:label runat="server" id="Output" /></p>

and

Output.Text = "The height of tree1 is:<br/>" + tree1.height + feet";

it should be:

Output.Text = "The height of tree1 is:<br/>" + tree1.height + "feet";
+1
source

Your question is similar to the previous question in StackOverflow: "StartTag: invalid element name" in default.aspx , which seems like a problem with configuring IIS.

From the link:

ASP.NET , ASP.NET ( ). .NET framework .

, :)

+1

, Tree Output, Default.aspx. Output.Text Default.aspx Tree. , , geoff " . Page_Load :

Default.aspx

<script runat="server">
protected void Page_Load(Object Source, EventArgs E)
{
  /* Begin C# Code!*/
  Tree tree1 = new Tree();
  tree1.Grow(3);
  Output.Text = tree1.Message();
}
</script>

Message() Output.Text. Tree tree1.height, this.height height. , feet, . , ". , " , feet. :

Test

public string Message()
{
  return "The height of tree1 is:<br/>" + height;
}

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

, , , , , .

( VS 2008 IDE)

+1

@BOSS, , aspnet_regiis ASP.NET IIS.

.NET framework "aspnet_regiis -i", .

: ASP.NET IIS (Aspnet_regiis.exe)

, IIS -:

-i aspnet_regiis , . .NET 2.0 , . aspnet_regiis -i ( aspnet_regiis .NET framework). , -i reset , . -i , interupt , . "-i" , , , , .NET framework.

From: Running "aspnet_regiis -i" Not Always the Best Choice

0
source

Source: https://habr.com/ru/post/1764267/


All Articles