I don't know if there is a more WebMethod -special way to do this, but in ASP.NET you would just set the status code for the Response Object . Something like that:
Response.Clear(); Response.StatusCode = 500; // or whatever code is appropriate Response.End;
Using standard error codes is an appropriate way to notify the consumer of an HTTP client about an error. Before ending the response, you can also Response.Write() send any messages. The formats for them are much less standardized, so you can create your own. But while the status code accurately reflects the answer, your JavaScript or any other client that consumes this service will understand the error.
David source share