Response.Write("Hello World!"); // Write to Response buffer Response.End(); // Stop processing and send response to client
if (isValid) { Response.Redirect("success.aspx"); // Redirect to success page } else { Response.Write("Invalid input"); // Write error message to response buffer Response.End(); // Stop processing and send response to client }This code example demonstrates how to use the End method to stop processing and send a response to the client in case of errors. In this case, if the input is not valid, an error message will be written to the response buffer and the End method will be called to stop processing and send the response. Package library: The System.Web namespace is part of the .NET Framework, which includes the necessary libraries for web applications and server-side programming.