Get exception code using C#

on Dec 21, 2017 01:43 AM

On page load I have some code within a try-catch block

If everything is ok and being processed I need it to return a repose status code of 200 and if there and error and it in the catch section also send a repose status code (i am not sure what the code for an error)

Here an example I found I need something like this

protected void Page_Load(object sender, System.EventArgs e)
    if (Common.CheckDatabaseConnection())
        this.LiteralMachineName.Text = Environment.MachineName;
        Response.Status = "503 ServiceUnavailable";
        Response.StatusCode = 503;
        Response.StatusDescription= "An error has occurred";
        throw new HttpException(503,string.Format("An internal error occurred in the Application on {0}",Environment.MachineName)); 


Download FREE API for Word, Excel and PDF in ASP.Net: Download