Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is what I did:</p> <p>In controller, I placed try catch:</p> <pre><code> try { //model = getmodelfromdb(); return View("MyView", model); } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return View("../Error/ShowException", ex); } </code></pre> <p>For custom view for 404, I did this in global.asax:</p> <pre><code> protected void Application_OnError( ) { var exception = Server.GetLastError( ); Elmah.ErrorSignal.FromCurrentContext().Raise(exception); Helper.SetSessionValue(SessionKeys.EXCEPTION, exception); Response.Redirect( "~/Error/ShowException"); } </code></pre> <p>For jqgrid, I did this in my controller:</p> <pre><code> [HttpPost] public ActionResult ListRecords( int page , DateTime? fromdate , DateTime? todate) { try { var list = FetchListFromDB(); var result = new { total = Math.Ceiling(list.Count / (decimal)Helper.PAGE_SIZE), page = page, //--- current page records = list.Count, //--- total items rows = list.List.Select(x =&gt; new { id = x.EntityID, cell = new string[] { x.Property1, x.Property2 } }).ToArray() }; return Json(result, JsonRequestBehavior.AllowGet); } catch (Exception ex) { var result = new { errorMessage = "An unexpected error occurred while fetching data. An automatic email has been generated for the support team who will address this issue shortly. Details: " + ex.Message, records = 0 }; Elmah.ErrorSignal.FromCurrentContext().Raise(ex); return Json(result, JsonRequestBehavior.AllowGet); } </code></pre> <p>And this in the View (in the jqgrid definition):</p> <pre><code> loadComplete:function(data) { if (data.errorMessage) { alert(data.errorMessage); } }, </code></pre> <p>In a general ajax scenario:</p> <pre><code> success: function(data) { if (data.errorMessage) { alert(data.errorMessage); } else { //... } }, </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload