ASP.NET Integration

This library is intended for ASP.NET projects that are not using MVC.

Setup

You need to have installed the OneTrueError server somewhere and created an application in it. Once you've done that you'll have a appKey and a sharedSecret which you can configure below.

Add the following code in global.asax:

var url = new Uri("http://yourServer/onetrueerror");
OneTrue.Configuration.Credentials(url, "13d82df603a845c7a27164c4fec19dd6", "6f0a0a7fac6d42caa7cc47bb34a6520b");
OneTrue.Configuration.CatchAspNetExceptions();

All unhandled exceptions will now be reported.

Context collections

These collections are generated by the ASP.NET library.

HTTP headers

All HTTP headers in the request that the application could not handle.

Uploaded files

Name, size and context type of all files that was uploaded in the request.

Form

All items in the HTTP form (name and value)

QueryString

Query string pairs (key and value).

Session

All session items (support for complex objects)

Customizations

This section describes how you can customize the built in features. You can also add your own context providers.

Error pages

The library contains a custom error page which can be activated (and shown) when an exception is caught.

To activate it add the following code:

var provider = new VirtualPathProviderBasedGenerator("~/Errors/");
OneTrue.Configuration.SetErrorPageGenerator(provider);

The code says that the library should look after error pages (either .aspx or .html) in the specified folder:

The library tries to find pages based on the HTTP code. If the code is 404 the library tries to find the following error pages:

  1. FileNotFound.aspx
  2. FileNotFound.html
  3. Error.aspx
  4. Error.html

That is, it tries to find a specific file first. If a specific file do not exist it tries to load a generic one.

ASPX pages

TO get information into your view, simply declare one of the following properties in your code behind.


| PropertyTypeDescription |
ErrorContext HttpErrorReporterContext Look in the Client API specification for more information
Exception Exception The caught exception


Example

public partial class NotFound : System.Web.UI.Page
{
	protected void Page_Load(object sender, EventArgs e)
	{

	}

	public Exception Exception { get; set; }

	public HttpErrorReporterContext ErrorContext { get; set; }
}

Then simnply display the error information in your HTML:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NotFound.aspx.cs" Inherits="OneTrueError.Client.AspNet.Demo.Errors.NotFound" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Failed to find <%= Exception.Message %></title>
</head>
<body>
	<form method="post" action="$URL$">
		<input type="hidden" value="$reportId$" name="reportId" />
        <div>
            Page is not found
        </div>
        <div>
            <%= ErrorContext.HttpStatusCode  %>
        </div>
		<div>
			<p>Could you please let us know how to reproduce it? Any information you	 give us will help us solve it faster.</p>
			<textarea rows="10" cols="40" name="Description"></textarea>
		</div>
    </form>
</body>
</html>

HTML

If you are just using HTML you can use the following template strings:


| Template textDescription |
{ErrorMessage} Exception message


example

[html] <!DOCTYPE html>

An error occurred

Looks like something went wrong!

Thanks for taking the time and letting us know about the issue.

If you allow us to collect additional error information we'll be able to analyze this error much faster.

I allow thy to collect the additional information.

Could you please let us know how to reproduce it? Any information you give us will help us solve it faster.

            <div class="AskForEmailAddress">
                <p>Enter your email address if you would like to receive status updates about this error.</p>
                <input type="text" name="email" placeholder="email address" />
            </div>
            <hr />
            <input type="submit" value="Send report" />
            <a href="/">Back to homepage</a>
        </div>
        <div style="clear: both;"></div>
    </form>
</div>

[/html]

Links

Follow us


Star

Monthly newsletter

OneTrueError news, exception best practices and feature insights.


Get in touch

Write us a line, we would love to help!

Improve page