Over a million developers have joined DZone.

OneTrueError and ASP.NET

DZone's Guide to

OneTrueError and ASP.NET

· ·
Free Resource

OneTrueError is my new startup which also is a member of Microsoft BizSpark. This post is about the client library for ASP.NET (WebForms/MVC/WebAPI). It will catch and handle all uncaught exceptions automatically. They are also uploaded to our site for analysis to enable us to suggest possible solutions

To get started you need to have an account at onetrueerror.com and download our nuget-packageOneTrueError.AspNet. Once you’ve completed that you’ll only have to add these lines of code to yourglobal.asax.


Now we’ll be able to detect and handle all uncaught exceptions. Simply do something which would generate an exception, like visiting a page that do not exist. You should get our default error page which looks like this:

If you inspect the error page HTTP headers you’ll see that we use correct status codes:

We also honor the requested type. If the caller wants XML we do provide XML. Same goes for JSON.


As you’ve might have seen, we collect a lot of context information to be able to provide you with possible error solutions. Some users do not like that and we can therefore enable you to allow them to choose if we can upload the report or not.

You simply change the initialization code:

OneTrue.Configuration.AskForPermission = true;

That changes the error page to:

You can also ask the user to provide details:

OneTrue.Configuration.AskForDetails = true;

To enable them to follow the progress of the error (and get notified when you’ve have completed the error) you change another flag:

OneTrue.Configuration.AskForEmail = true;

You can of course combine them:


You do not have to use our error page. You can create your own ASPX or HTML page (those works for WebApi/MVC too). To activate it, use the following command:


Here is a sample that I’ve made:

< %@ Page Language="C#" AutoEventWireup="true" CodeBehind="Error.aspx.cs" Inherits="TestWebApp.Views.WebForm1" %>
< %@ Import Namespace="OneTrueError.Reporting" %>
< !DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>OneSite - Deadly error</title>
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Butcherman"/>
<body style="background: #000; color: red;font-family: Butcherman; text-align: center; font-size: 1.2em">
    <h1>We are all doomed</h1>
    <img runat="server" src="~/Images/doomed.jpg"/>
    <form id="form1" runat="server">
    < %: ((Exception)Context.Items["Exception"]).Message  %>


You can also use a callback to provide different error pages for different errors:

public class WebApiApplication : System.Web.HttpApplication
	protected void Application_Start()
		OneTrue.Configuration.Credentials("appKeyThatYouGot", "sharedSecretThatYouGot");


	private string ErrorPageGenerator(HttpErrorReporterContext context)
		var errorPage = context.HttpContext.Response.StatusCode == 404
			? "~/Views/404.aspx"
			: "~/Views/Error.html";

		// class in our library
		return PageBuilder.Build(errorPage, context);

Context information

At our website you can see all information about the HTTP request, response, sessions and cookies.


Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}