error on Response.End(): Unable to evaluate expression ...

Discussion in 'ASP .Net' started by tbh, Feb 11, 2008.

  1. tbh

    tbh Guest

    in an error path in an aspx script under DotNet 2, IIS6, Win2003 Server I
    get the following error (which I don't understand) on Respone.End():

    {Unable to evaluate expression because the code is optimized or a native
    frame is on top of the call stack.}

    i'm attempting to abort execution with an error and have tried for example:
    System.Web.HttpResponse response =
    System.Web.HttpContext.Current.Response;
    response.Clear();

    response.Status = "400 Bad Request";

    response.End();

    inside try {} catch {}. when I step through with a debugger control
    transfers after response.End() to a catch clause with the exception listed
    above.

    any ideas what could be causing this and what I can do about it? (i'd like
    to avoid 5xx errors in favor of 4xx ones when the problem is a request for
    something that isn't there -- as opposed to badly broken code.)

    cheers,

    Tim Hanson
    tbh, Feb 11, 2008
    #1
    1. Advertising

  2. tbh

    bruce barker Guest

    Response.End(), aborts the current thread. if you call inside a try block,
    you will catch the thread abort. if you use a try block, you'll need to catch
    the abort and rethrow it.

    -- bruce (sqlwork.com)


    "tbh" wrote:

    > in an error path in an aspx script under DotNet 2, IIS6, Win2003 Server I
    > get the following error (which I don't understand) on Respone.End():
    >
    > {Unable to evaluate expression because the code is optimized or a native
    > frame is on top of the call stack.}
    >
    > i'm attempting to abort execution with an error and have tried for example:
    > System.Web.HttpResponse response =
    > System.Web.HttpContext.Current.Response;
    > response.Clear();
    >
    > response.Status = "400 Bad Request";
    >
    > response.End();
    >
    > inside try {} catch {}. when I step through with a debugger control
    > transfers after response.End() to a catch clause with the exception listed
    > above.
    >
    > any ideas what could be causing this and what I can do about it? (i'd like
    > to avoid 5xx errors in favor of 4xx ones when the problem is a request for
    > something that isn't there -- as opposed to badly broken code.)
    >
    > cheers,
    >
    > Tim Hanson
    >
    >
    >
    bruce barker, Feb 11, 2008
    #2
    1. Advertising

  3. tbh

    tbh Guest

    thanks!

    "bruce barker" <> wrote in message
    news:...
    > Response.End(), aborts the current thread. if you call inside a try block,
    > you will catch the thread abort. if you use a try block, you'll need to
    > catch
    > the abort and rethrow it.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "tbh" wrote:
    >
    >> in an error path in an aspx script under DotNet 2, IIS6, Win2003 Server I
    >> get the following error (which I don't understand) on Respone.End():
    >>
    >> {Unable to evaluate expression because the code is optimized or a
    >> native
    >> frame is on top of the call stack.}
    >>
    >> i'm attempting to abort execution with an error and have tried for
    >> example:
    >> System.Web.HttpResponse response =
    >> System.Web.HttpContext.Current.Response;
    >> response.Clear();
    >>
    >> response.Status = "400 Bad Request";
    >>
    >> response.End();
    >>
    >> inside try {} catch {}. when I step through with a debugger control
    >> transfers after response.End() to a catch clause with the exception
    >> listed
    >> above.
    >>
    >> any ideas what could be causing this and what I can do about it? (i'd
    >> like
    >> to avoid 5xx errors in favor of 4xx ones when the problem is a request
    >> for
    >> something that isn't there -- as opposed to badly broken code.)
    >>
    >> cheers,
    >>
    >> Tim Hanson
    >>
    >>
    >>
    tbh, Feb 11, 2008
    #3
    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.
Similar Threads
  1. csgraham74

    Response.Redirect at a response.end

    csgraham74, Jun 16, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    855
    Karl Seguin
    Jun 16, 2005
  2. Replies:
    9
    Views:
    4,714
  3. Jason luo
    Replies:
    3
    Views:
    509
    Peter Ammon
    Aug 19, 2004
  4. Ajit Goel
    Replies:
    0
    Views:
    420
    Ajit Goel
    Apr 16, 2007
  5. Ajit Goel
    Replies:
    0
    Views:
    1,190
    Ajit Goel
    Apr 16, 2007
Loading...

Share This Page