Skip to content

Commit 79937db

Browse files
Demonstrate config for ASP.NET Core 6.0+
1 parent c130359 commit 79937db

File tree

2 files changed

+85
-25
lines changed

2 files changed

+85
-25
lines changed

platform-includes/configuration/config-intro/dotnet.aspnetcore.mdx

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,31 @@
11
Options can be set by passing a callback to the `UseSentry()` method which will
22
pass the option object along for modifications:
33

4-
ASP.NET Core 2.x:
5-
4+
ASP.NET Core 6.0+:
65

76
```csharp
8-
public static IWebHost BuildWebHost(string[] args) =>
9-
WebHost.CreateDefaultBuilder(args)
10-
// Add the following line:
11-
.UseSentry(o =>
12-
{
13-
o.Dsn = "___PUBLIC_DSN___";
14-
o.MaxBreadcrumbs = 50;
15-
o.Debug = true;
16-
o.SendDefaultPii = true;
17-
});
7+
var builder = WebApplication.CreateBuilder(args);
8+
9+
builder.WebHost.UseSentry(o => {
10+
o.Dsn = "___PUBLIC_DSN___";
11+
o.MaxBreadcrumbs = 50;
12+
o.Debug = true;
13+
o.SendDefaultPii = true;
14+
});
1815
```
1916

20-
ASP.NET Core 3.0:
17+
```fsharp
18+
let builder = WebApplication.CreateBuilder(args)
2119
20+
builder.WebHost.UseSentry(fun o ->
21+
o.Dsn <- "___PUBLIC_DSN___"
22+
o.MaxBreadcrumbs <- 50
23+
o.Debug <- true
24+
o.SendDefaultPii <- true
25+
) |> ignore
26+
```
27+
28+
ASP.NET Core 3.0:
2229

2330
```csharp
2431
public static IHostBuilder CreateHostBuilder(string[] args) =>
@@ -36,6 +43,47 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
3643
});
3744
```
3845

46+
```fsharp
47+
let CreateHostBuilder args =
48+
Host.CreateDefaultBuilder(args)
49+
.ConfigureWebHostDefaults(fun webBuilder ->
50+
// Add the following line:
51+
webBuilder.UseSentry(fun o ->
52+
o.Dsn <- "___PUBLIC_DSN___"
53+
o.MaxBreadcrumbs <- 50
54+
o.Debug <- true
55+
o.SendDefaultPii <- true
56+
) |> ignore
57+
)
58+
```
59+
60+
ASP.NET Core 2.x:
61+
62+
```csharp
63+
public static IWebHost BuildWebHost(string[] args) =>
64+
WebHost.CreateDefaultBuilder(args)
65+
// Add the following line:
66+
.UseSentry(o =>
67+
{
68+
o.Dsn = "___PUBLIC_DSN___";
69+
o.MaxBreadcrumbs = 50;
70+
o.Debug = true;
71+
o.SendDefaultPii = true;
72+
});
73+
```
74+
75+
```fsharp
76+
let BuildWebHost args =
77+
WebHost.CreateDefaultBuilder(args)
78+
// Add the following line:
79+
.UseSentry(fun o ->
80+
o.Dsn <- "___PUBLIC_DSN___"
81+
o.MaxBreadcrumbs <- 50
82+
o.Debug <- true
83+
o.SendDefaultPii <- true
84+
)
85+
```
86+
3987
Additionally, you can set your options on `appsettings.json` when using `UseSentry()`:
4088

4189

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
1-
Add Sentry to `Program.cs` through the `WebHostBuilder`:
2-
3-
ASP.NET Core 2.x:
1+
Add Sentry to `Program.cs` through the `WebApplicationBuilder`:
42

3+
ASP.NET Core 6.0+:
54

65
```csharp
7-
public static IWebHost BuildWebHost(string[] args) =>
8-
WebHost.CreateDefaultBuilder(args)
9-
// Add the following line:
10-
.UseSentry("___PUBLIC_DSN___");
6+
var builder = WebApplication.CreateBuilder(args);
7+
8+
builder.WebHost.UseSentry("___PUBLIC_DSN___");
119
```
1210

1311
```fsharp
14-
let BuildWebHost args =
15-
WebHost.CreateDefaultBuilder(args)
16-
// Add the following line:
17-
.UseSentry("___PUBLIC_DSN___")
12+
let builder = WebApplication.CreateBuilder(args)
13+
14+
builder.WebHost.UseSentry("___PUBLIC_DSN___") |> ignore
1815
```
1916

2017
ASP.NET Core 3.0:
2118

22-
2319
```csharp
2420
public static IHostBuilder CreateHostBuilder(string[] args) =>
2521
Host.CreateDefaultBuilder(args)
@@ -38,3 +34,19 @@ let CreateHostBuilder args =
3834
webBuilder.UseSentry("___PUBLIC_DSN___") |> ignore
3935
)
4036
```
37+
38+
ASP.NET Core 2.x:
39+
40+
```csharp
41+
public static IWebHost BuildWebHost(string[] args) =>
42+
WebHost.CreateDefaultBuilder(args)
43+
// Add the following line:
44+
.UseSentry("___PUBLIC_DSN___");
45+
```
46+
47+
```fsharp
48+
let BuildWebHost args =
49+
WebHost.CreateDefaultBuilder(args)
50+
// Add the following line:
51+
.UseSentry("___PUBLIC_DSN___")
52+
```

0 commit comments

Comments
 (0)