Skip to content

Commit 14269b6

Browse files
committed
Updated the readme for web api
1 parent eec9ca7 commit 14269b6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

Source/Platforms/WebApi/NuGet/readme.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ the web.config Exceptionless section.
2323

2424
<exceptionless apiKey="API_KEY_HERE" />
2525

26-
Finally, you must import the "Exceptionless" namespace and call the following line
26+
Next, you must import the "Exceptionless" namespace and call the following line
2727
of code to start reporting unhandled exceptions. You will need to run code during
2828
application startup and pass it an HttpConfiguration instance. Please note that this
2929
code is normally placed inside of the WebApiConfig classes Register method.
@@ -34,6 +34,23 @@ If you are hosting Web API inside of ASP.NET, you would register Exceptionless l
3434

3535
Exceptionless.ExceptionlessClient.Default.RegisterWebApi(GlobalConfiguration.Configuration)
3636

37+
Finally, if you are targetting WebApi 2.1 or newer you will need to copy the following
38+
ExceptionLogger into your project and register it as a service.
39+
40+
using Exceptionless.Plugins;
41+
public class ExceptionlessExceptionLogger : ExceptionLogger {
42+
public override void Log(ExceptionLoggerContext context) {
43+
var contextData = new ContextData();
44+
contextData.MarkAsUnhandledError();
45+
contextData.SetSubmissionMethod("ExceptionLogger");
46+
contextData.Add("HttpActionContext", context.ExceptionContext.ActionContext);
47+
48+
context.Exception.ToExceptionless(contextData).Submit();
49+
}
50+
}
51+
52+
config.Services.Add(typeof(IExceptionLogger), new ExceptionlessExceptionLogger());
53+
3754
Please visit the wiki https://github.com/exceptionless/Exceptionless.Net/wiki/Sending-Events
3855
for examples on sending events to Exceptionless.
3956

Source/Samples/SampleMvc/Views/Home/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
$.ajax({
7676
type: "POST",
7777
url: "/api/values",
78-
data: JSON.stringify(1),
78+
data: JSON.stringify({ Name: "Test" }),
7979
contentType: "application/json; charset=utf-8",
8080
dataType: "json",
8181
success: function (data) { alert(data); },

0 commit comments

Comments
 (0)