die() or exit() functionality in ASP.NET

It depends on where you are in your code, but you want a way of getting the Response object.

From here, you can call HttpResponse.End().

This method sends the buffer to the client, raises the EndRequest event and throws a ThreadAbortException to stop the rest of the page executing.


You're looking for Response.End()

The End method causes the Web server to stop processing the script and return the current result. The remaining contents of the file are not processed.

The documentation for php's exit() states:

Terminates execution of the script. Shutdown functions and object destructors will always be executed even if exit is called.

exit is a language construct and it can be called without parentheses if no status is passed.

They're not exactly equivalent, but that's mainly down to the differences between the way the two frameworks work.

You've got to take care when calling Response.End because it will throw an exception if there is any script left to process (Response.Redirect exhibits the same behaviour). This can cause you performance problems if this is done frequently.