Click here to Skip to main content
13,291,084 members (58,351 online)
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 23 Jan 2014

OneTrueError and ASP.NET

, 4 Aug 2014
Rate this:
Please Sign up or sign in to vote.
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 … Continue reading →

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 and download our nuget-package OneTrueError.AspNet. Once you’ve completed that you’ll only have to add these lines of code to your global.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:

404-error-code 402-error-code

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

return-xml return-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="">
<head runat="server">
    <title>OneSite - Deadly error</title>
    <link rel="stylesheet" type="text/css" href=""/>
<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.


The collected information (exceptions etc) are presented in our dashboard:


This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)


About the Author

Founder 1TCompany AB
Sweden Sweden
Skip logfiles, try automated error handling!

I'm one of the founders of codeRR, a .NET service which takes care of everything related to exceptions, so that you can focus on writing code.

blog | twitter

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 4 Aug 2014
Article Copyright 2014 by jgauffin
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid