ASP.net MVC Custom error json result

 

//=============Custom Error Starts

//private JsonResult ThrowJSONError(Exception e)

//{

//    Response.StatusCode = (int)System.Net.HttpStatusCode.BadRequest;

//    //e.StackTrace

//    // return Json(new { Message = e.Message });

//    return Json(new { Error = "Uh oh!" });

//}


//public ActionResult DivideByZero()

//{

//    try

//    {

//        throw new DivideByZeroException();

//    }

//    catch (DivideByZeroException e)

//    {

//        return ThrowJSONError(e);

//    }


//}

//=============Custom Error Ends

Comments

Popular posts from this blog

iCalendar - Create .ics file using C#

FUNNY ABBREVIATIONS