From ec8dc5419ca9d476df234af6a14ac4c6912dc22c Mon Sep 17 00:00:00 2001 From: crystalqdm Date: Tue, 6 Jun 2023 14:02:25 +1200 Subject: [PATCH] Update READMEs --- Mindscape.Raygun4Net.Mvc/README.md | 4 ++ Mindscape.Raygun4Net.WebApi/README.md | 61 ++++++++++++++++++++++++--- README.md | 43 +++++-------------- 3 files changed, 69 insertions(+), 39 deletions(-) diff --git a/Mindscape.Raygun4Net.Mvc/README.md b/Mindscape.Raygun4Net.Mvc/README.md index 2fa30afbb..32c214a71 100644 --- a/Mindscape.Raygun4Net.Mvc/README.md +++ b/Mindscape.Raygun4Net.Mvc/README.md @@ -13,6 +13,10 @@ The main classes can be found in the Mindscape.Raygun4Net namespace. Usage ====== +The following instructions are for ASP.NET *Framework* Web API. For instructions for how to install Raygun for ASP.NET Core Web API, see the `Mindscape.Raygun4Net.AspNetCore` provider [here](../Mindscape.Raygun4Net.AspNetCore/README.md). + +--- + Add a section to configSections:
diff --git a/Mindscape.Raygun4Net.WebApi/README.md b/Mindscape.Raygun4Net.WebApi/README.md index 71f4d4c51..2f900937e 100644 --- a/Mindscape.Raygun4Net.WebApi/README.md +++ b/Mindscape.Raygun4Net.WebApi/README.md @@ -13,24 +13,58 @@ The main classes can be found in the Mindscape.Raygun4Net namespace. Usage ====== -Add a section to configSections: +The following instructions are for ASP.NET *Framework* Web API. For instructions for how to install Raygun for ASP.NET Core Web API, see the `Mindscape.Raygun4Net.AspNetCore` provider [here](../Mindscape.Raygun4Net.AspNetCore/README.md). +--- + +Install the **Mindscape.Raygun4Net.WebApi** NuGet package into your project. You can either use the below dotnet CLI command, or the NuGet management GUI in the IDE you use. + +```bash +dotnet add package Mindscape.Raygun4Net.WebApi ``` + +In your Web.config file, find or add a `` element, which should be nested under the `` element, and add the following entry: + +```xml
``` -Add the Raygun settings configuration block from above: +Then reference it by adding the following line somewhere after the `configSections` tag. Your app API key is displayed when you create a new application in your Raygun account, or can be viewed in the application settings. `RaygunSettings` has many options which can be found [here](https://raygun.com/documentation/language-guides/dotnet/crash-reporting/webapi/#exclude-errors-by-http-status-code). +```xml + ``` - -``` + Now you can either setup Raygun to send unhandled exceptions automatically or/and send exceptions manually. -To send unhandled exceptions automatically, go to the WebApiConfig class in your project. In the static Register method, call the static RaygunWebApiClient.Attach method. +--- + +To send unhandled exceptions automatically, go to your `WebApiConfig` class (typically in the `App_Start` directory). Call the static `RaygunWebApiClient.Attach(config)` method from within the `Register` method: ```csharp -RaygunWebApiClient.Attach(config); +using Mindscape.Raygun4Net.WebApi; +``` + +```csharp +public static class WebApiConfig +{ + public static void Register(HttpConfiguration config) + { + RaygunWebApiClient.Attach(config); + + // Web API routes here + } +} +``` + +If you haven't already, make sure to register the `WebApiConfig` class in the `Application_Start` method in your `Global.asax.cs` file: + +```csharp +protected void Application_Start() +{ + GlobalConfiguration.Configure(WebApiConfig.Register); +} ``` Anywhere in you code, you can also send exception reports manually simply by creating a new instance of the RaygunWebApiClient and call one of the Send or SendInBackground methods. @@ -47,6 +81,21 @@ catch (Exception e) } ``` +--- + +TLS Configuration +------------------- + +Raygun's ingestion nodes [require TLS 1.1 or TLS 1.2](https://raygun.com/documentation/privacy-security/transport-layer-security/). If you are using .NET 4.5 or earlier, you may need to enable these protocols in your application. This is done by updating the protocol property in the `Application_Start` method in your `Global.asax.cs` file: + +```csharp +protected void Application_Start() +{ + // Enable TLS 1.1 and TLS 1.2 with future support for TLS 3 + ServicePointManager.SecurityProtocol |= (SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls3 ); +} +``` + Providing a custom RaygunClient to the automatic exception handlers =================================================================== diff --git a/README.md b/README.md index dfbd58508..c43691f41 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,8 @@ Projects built with the following frameworks are supported: * .NET 3.5 and 4.0 Client Profile * .NET Core 1.0, 2.0, 3.0+ * ASP.NET -* Mvc -* WebApi +* ASP.NET MVC +* ASP.NET WebApi * WinForms, WPF, console apps etc * Windows 8 * WinRT @@ -223,44 +223,21 @@ To do this, get your Http Application to implement the IRaygunApplication interf The http module will use the RaygunClient returned from this method to send the unhandled exceptions. In this method you can setup any additional options on the RaygunClient instance that you need - more information about each feature is described at the end of this file. -### MVC +### ASP.NET MVC As of version 4.0.0, Mvc support has been moved into a new NuGet package. -If you have an Mvc project, please uninstall the Raygun4Net NuGet package and install the Mindscape.Raygun4Net.Mvc NuGet package instead. -The NuGet package will include a readme containing everything you need to know about using it. +If you have an Mvc project, please uninstall the Raygun4Net NuGet package and install the `Mindscape.Raygun4Net.Mvc` NuGet package instead. -The Mvc and WebApi NuGet packages can be installed in the same project. +Once the package is installed, see the [package README](/Mindscape.Raygun4Net.Mvc/README.md) for instructions on configuration. -### Web Api - -As of version 4.0.0, WebApi support has been moved into a new NuGet package. -If you have a WebApi project, please uninstall the Raygun4Net NuGet package and install the Mindscape.Raygun4Net.WebApi NuGet package instead. - -Once the package is installed, go to the `WebApiConfig` class in your project. -In the static `Register` method, call the static `RaygunWebApiClient.Attach` method. - -```csharp -RaygunWebApiClient.Attach(config); -``` +The Mvc and WebApi NuGet packages can be installed in the same project safely. -Note that you may experience errors if you include the HTTP Module in the `` section of your `web.config`. -The HTTP module is only required if you are using MVC or regular ASP.NET - all WebApi errors are caught using -`RaygunWebApiClient.Attach`. +### ASP.NET Web API -To include the HTTP request details, pass in the current request message to the client's SetCurrentHTTPRequest method when manually sending exceptions. +As of version 4.0.0, WebApi support has been moved into a new NuGet package. +If you have a WebApi project, please uninstall the Raygun4Net NuGet package and install the `Mindscape.Raygun4Net.WebApi` NuGet package instead. -```csharp -try -{ - // Do something here that might go wrong -} -catch (Exception e) -{ - var client = new RaygunWebApiClient(); - client.SetCurrentHttpRequest(ActionContext.Request); - client.SendInBackground(e); -} -``` +Once the package is installed, see the [package README](/Mindscape.Raygun4Net.WebApi/README.md) for instructions on configuration. The Mvc and WebApi NuGet packages can be installed in the same project safely.