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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • tbh

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

    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.Http Response response =
    System.Web.Http Context.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


  • =?Utf-8?B?YnJ1Y2UgYmFya2Vy?=

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

    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.Http Response response =
    System.Web.Http Context.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
    >
    >
    >

    Comment

    • tbh

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

      thanks!

      "bruce barker" <brucebarker@di scussions.micro soft.comwrote in message
      news:45346923-D4E2-4B8B-8115-50CEB7B33A64@mi crosoft.com...
      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.Http Response response =
      >System.Web.Htt pContext.Curren t.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
      >>
      >>
      >>

      Comment

      Working...