470,819 Members | 1,621 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,819 developers. It's quick & easy.

{"Parser Error: The Runat attribute must have the value Server." }

I'm getting a {"Parser Error: The Runat attribute must have the value
Server." } error when I try to get the Server.GetlastError() in the
Global.asax codebehind.

Why am I getting this?

I tried to remove the code-behind and add the <script language="C#"
runat="server"> but that fails as well.

The code is simply:
protected void Application_Error( object src, EventArgs e )
{
Exception exc = Server.GetLastError(); // fails here
Trace.Write (exc.Message.ToString());
}

I've found nothing anywhere on this.

Thanks for your help

--Andy
Nov 19 '05 #1
3 5873
Hi Andy,

The error is probably on the .aspx page or .ascx.

Here is a code snippet that will give this exact error:

<body>
<form id="Form1" method="post" runat="server">
<asp:CheckBoxList id="CheckBoxList1" runat=""></asp:CheckBoxList>
</form>
</body>

Note that the runat attribute do NOT have server value. You can correct the
error by writing the as this:

<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:CheckBoxList id="CheckBoxList1"
runat="server"></asp:CheckBoxList>
</form>
</body>

--------------------------
Jean-Claude Morin, MCP
Software Developer
2k1Soft/kCentric, Canada
"ADavidson" <AD*******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I'm getting a {"Parser Error: The Runat attribute must have the value
Server." } error when I try to get the Server.GetlastError() in the
Global.asax codebehind.

Why am I getting this?

I tried to remove the code-behind and add the <script language="C#"
runat="server"> but that fails as well.

The code is simply:
protected void Application_Error( object src, EventArgs e )
{
Exception exc = Server.GetLastError(); // fails here
Trace.Write (exc.Message.ToString());
}

I've found nothing anywhere on this.

Thanks for your help

--Andy

Nov 19 '05 #2
Try this :

protected void Application_Error(Object sender, EventArgs e)
{
ExceptionHandler.LogException exc = new ExceptionHandler.LogException();
exc.HandleException(Server.GetLastError().GetBaseE xception());
//whatever you want to do here...
}

See Peter Bromberg's excellent article :
"Build a Really Useful ASP.NET Exception Engine"
at http://www.eggheadcafe.com/articles/20030816.asp


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa˝ol
Ven, y hablemos de ASP.NET...
======================

"ADavidson" <AD*******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I'm getting a {"Parser Error: The Runat attribute must have the value
Server." } error when I try to get the Server.GetlastError() in the
Global.asax codebehind.

Why am I getting this?

I tried to remove the code-behind and add the <script language="C#"
runat="server"> but that fails as well.

The code is simply:
protected void Application_Error( object src, EventArgs e )
{
Exception exc = Server.GetLastError(); // fails here
Trace.Write (exc.Message.ToString());
}

I've found nothing anywhere on this.

Thanks for your help

--Andy


Nov 19 '05 #3
Thanks for the responses i reviewed my code and found the answer.... I'm an
idiot and suffered a major brain cramp..

To test the catch of the error I mistyped a runat in the aspx code.. So
that was the 'error' I was getting, the correct error as it turns out...
Good to see that i doubt working code...

Thanks again for your efforts, and i'm sorry to waste your time.

-Andy

"Juan T. Llibre" wrote:
Try this :

protected void Application_Error(Object sender, EventArgs e)
{
ExceptionHandler.LogException exc = new ExceptionHandler.LogException();
exc.HandleException(Server.GetLastError().GetBaseE xception());
//whatever you want to do here...
}

See Peter Bromberg's excellent article :
"Build a Really Useful ASP.NET Exception Engine"
at http://www.eggheadcafe.com/articles/20030816.asp


Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Espa├▒ol
Ven, y hablemos de ASP.NET...
======================

"ADavidson" <AD*******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I'm getting a {"Parser Error: The Runat attribute must have the value
Server." } error when I try to get the Server.GetlastError() in the
Global.asax codebehind.

Why am I getting this?

I tried to remove the code-behind and add the <script language="C#"
runat="server"> but that fails as well.

The code is simply:
protected void Application_Error( object src, EventArgs e )
{
Exception exc = Server.GetLastError(); // fails here
Trace.Write (exc.Message.ToString());
}

I've found nothing anywhere on this.

Thanks for your help

--Andy


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Martin Colmenares | last post: by
3 posts views Thread by filip.norrgard | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.