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

Discussion in 'ASP .Net' started by =?Utf-8?B?QURhdmlkc29u?=, Mar 3, 2005.

  1. 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
     
    =?Utf-8?B?QURhdmlkc29u?=, Mar 3, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?QURhdmlkc29u?=

    Jc Morin Guest

    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" <> wrote in message
    news:...
    > 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
     
    Jc Morin, Mar 3, 2005
    #2
    1. Advertising

  3. 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




    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" <> wrote in message
    news:...
    > 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
     
    Juan T. Llibre, Mar 4, 2005
    #3
  4. Re: {"Parser Error: The Runat attribute must have the value Server

    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().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
    >
    >
    >
    >
    > 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" <> wrote in message
    > news:...
    > > 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

    >
    >
    >
    >
     
    =?Utf-8?B?QURhdmlkc29u?=, Mar 4, 2005
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page