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

G

Guest

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
 
J

Jc Morin

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>
 
J

Juan T. Llibre

Try this :

protected void Application_Error(Object sender, EventArgs e)
{
ExceptionHandler.LogException exc = new ExceptionHandler.LogException();
exc.HandleException(Server.GetLastError().GetBaseException());
//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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top