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

T

tbh

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
 
B

bruce barker

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)
 
T

tbh

thanks!

bruce barker said:
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)
 

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,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top