Skip to content
74 changes: 61 additions & 13 deletions platform-includes/configuration/config-intro/dotnet.aspnetcore.mdx
Original file line number Diff line number Diff line change
@@ -1,24 +1,31 @@
Options can be set by passing a callback to the `UseSentry()` method which will
pass the option object along for modifications:

ASP.NET Core 2.x:

ASP.NET Core 6.0+:

```csharp
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry(o =>
{
o.Dsn = "___PUBLIC_DSN___";
o.MaxBreadcrumbs = 50;
o.Debug = true;
o.SendDefaultPii = true;
});
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseSentry(o => {
o.Dsn = "___PUBLIC_DSN___";
o.MaxBreadcrumbs = 50;
o.Debug = true;
o.SendDefaultPii = true;
});
```

ASP.NET Core 3.0:
```fsharp
let builder = WebApplication.CreateBuilder(args)

builder.WebHost.UseSentry(fun o ->
o.Dsn <- "___PUBLIC_DSN___"
o.MaxBreadcrumbs <- 50
o.Debug <- true
o.SendDefaultPii <- true
) |> ignore
```

ASP.NET Core 3.0:

```csharp
public static IHostBuilder CreateHostBuilder(string[] args) =>
Expand All @@ -36,6 +43,47 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
});
```

```fsharp
let CreateHostBuilder args =
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(fun webBuilder ->
// Add the following line:
webBuilder.UseSentry(fun o ->
o.Dsn <- "___PUBLIC_DSN___"
o.MaxBreadcrumbs <- 50
o.Debug <- true
o.SendDefaultPii <- true
) |> ignore
)
```

ASP.NET Core 2.x:

```csharp
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry(o =>
{
o.Dsn = "___PUBLIC_DSN___";
o.MaxBreadcrumbs = 50;
o.Debug = true;
o.SendDefaultPii = true;
});
```

```fsharp
let BuildWebHost args =
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry(fun o ->
o.Dsn <- "___PUBLIC_DSN___"
o.MaxBreadcrumbs <- 50
o.Debug <- true
o.SendDefaultPii <- true
)
```

Additionally, you can set your options on `appsettings.json` when using `UseSentry()`:


Expand Down
36 changes: 24 additions & 12 deletions platform-includes/getting-started-config/dotnet.aspnetcore.mdx
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
Add Sentry to `Program.cs` through the `WebHostBuilder`:

ASP.NET Core 2.x:
Add Sentry to `Program.cs` through the `WebApplicationBuilder`:

ASP.NET Core 6.0+:

```csharp
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry("___PUBLIC_DSN___");
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseSentry("___PUBLIC_DSN___");
```

```fsharp
let BuildWebHost args =
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry("___PUBLIC_DSN___")
let builder = WebApplication.CreateBuilder(args)

builder.WebHost.UseSentry("___PUBLIC_DSN___") |> ignore
```

ASP.NET Core 3.0:


```csharp
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
Expand All @@ -38,3 +34,19 @@ let CreateHostBuilder args =
webBuilder.UseSentry("___PUBLIC_DSN___") |> ignore
)
```

ASP.NET Core 2.x:

```csharp
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry("___PUBLIC_DSN___");
```

```fsharp
let BuildWebHost args =
WebHost.CreateDefaultBuilder(args)
// Add the following line:
.UseSentry("___PUBLIC_DSN___")
```
Loading