ASP.NET MVC 5 Integration

This client library will provide both ASP.NET and MVC with specific context information for Coderr.


Apart from detecting and uploading uncaught exceptions, the library also provides the following features.

Error pages

The library has built in support for error pages.

To use the ones included in the library, add the following in global.asax (after the Err.Configuration.Credentials() line):


Custom error pages

You can include your own views instead of the built in pages.


@model Coderr.Client.AspNet.Mvc5.CoderrViewModel

<h1>Internal Server Error</h1>
    We've experienced a malfunction in the core crystal cooling. The ship will explode within five seconds.


Views should be named as the HTTP codes are defined in the HttpStatusCode enum in .NET and be placed in the Views/Errors folder.

The Error.cshtml view is displayed if no other view matches.


If it's enough to control the error handling through only views you can create your own ErrorController. Create it like any other controller in the Controllers folder.

The action methods should be name like the views. i.e. public ActionResult InternalServer().

The information provided by Coderr is represented as CoderrViewModel. Take it as a parameter to your action methods.


public class ErrorController : Controller
    public ActionResult Index(CoderrViewModel model)
        return View("Error", model);

    public ActionResult NotFound(CoderrViewModel model)
        return View(model);

    public ActionResult InternalServerError(CoderrViewModel model)
        return View(model);


Custom formats

An error object will be returned if XML or JSON is requested by the HTTP client.


  "error": { 
	"msg": "The error message", 
	"reportId": "Unique error id"
  hint: "Use the report id when contacting us if you need further assistance." 


<Error ReportId="Unique error id" hint="Use the report id when contacting us if you need further assistance">
	Error messgae

Context collections

To learn more about the included ASP.NET specific context collections like HTTP Request, read here


The controller name is collected.



Information about the route that MVC took is collected.



TempData is collected if set.


TempData["DemoKey"] = new {
		Amount = 20000,
		Expires = DateTime.UtcNow.AddMinutes(5)


ViewData / ViewBag

The ViewBag and/or ViewData is collected if specified.


ViewBag.Title = "Hello";
ViewBag.Model = new
	state = "Running",
	Collected = true



Edit page at GitHub Create a documentation ticket Ask a question This page is generated using the open source project MarkdownWeb.