Skip to content

docs(dotnet): Fix the code samples on the ASP.NET tracing pages - #20828

Merged
ric-oliv merged 2 commits into
masterfrom
docs/dotnet-aspnet-span-samples
Nov 18, 2026
Merged

ric-oliv merged 2 commits into
masterfrom
docs/dotnet-aspnet-span-samples

Conversation

@ric-oliv

@ric-oliv ric-oliv commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

DESCRIBE YOUR PR

The code samples on the ASP.NET Core and ASP.NET tracing pages don't compile when you paste them into a project.

On the ASP.NET Core page, the try block ends without a return, so the compiler reports CS0161. The sample now returns Ok(id), finishes the span with the exception in the catch, and drops the unused using Microsoft.Extensions.Logging;.

The ASP.NET sample had three errors. [HttpGet("/person/{id}")] doesn't compile in MVC 5, because its HttpGetAttribute takes no route, and SentrySdk needs using Sentry; on .NET Framework. It also had the same missing return. I built both fixed samples against the 7.0.0 packages, the ASP.NET one for .NET Framework 4.8 with MVC 5.3.

The ASP.NET page also said transactions are named <HTTP method> <Route>. Sentry.AspNet names them after the request path, and since that name comes from the URL, Sentry replaces parts that look like IDs: a request to /person/42 shows up as GET /person/*. I replaced that sentence, linked to the troubleshooting page that shows how to set the name yourself, and dropped the controller sample that went with it.

The Global.asax.cs setup sample on the same page didn't compile either. The DSN wasn't quoted and had no semicolon, and SentrySdk needed using Sentry;. I fixed both, and removed the comment saying the DSN comes from Web.config, along with its using System.Configuration;.

Refs getsentry/sentry-dotnet#5700

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.
Select exactly one option. For deadlines, replace YYYY-MM-DD with the due date. You can update this information later by editing the PR description.

  • Urgent deadline (GA date, etc.): YYYY-MM-DD
  • Other deadline: YYYY-MM-DD
  • No deadline: Not urgent, can wait up to 1 week+

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
sentry-docs Ready Ready Preview Nov 17, 2026 11:59am UTC
1 Skipped Deployment
Project Deployment Actions Updated
develop-docs Ignored Ignored Preview Nov 17, 2026 11:59am UTC

Request Review

@github-actions github-actions Bot added the Priority: Normal Docs review has no urgent deadline label Nov 16, 2026
@codeowner-assignment
codeowner-assignment Bot requested a review from a team November 16, 2026 13:50
@ric-oliv ric-oliv changed the title docs(dotnet): Fix the span samples on the ASP.NET tracing pages docs(dotnet): Fix the code samples on the ASP.NET tracing pages Nov 17, 2026
ric-oliv and others added 2 commits November 17, 2026 12:49
Both span samples were missing a return, and the ASP.NET one also used an HttpGet route that
MVC 5 doesn't support and was missing using Sentry. The ASP.NET page also said transactions are
named after the route, but Sentry.AspNet names them after the request path.

Refs getsentry/sentry-dotnet#5700

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…al.asax

Sentry.AspNet names transactions after the request path, and Relay replaces path parts that look like IDs, so a request to /person/42 shows up as GET /person/*, not GET /person/42. Say so and link the troubleshooting page that shows how to set the name.

The Global.asax.cs sample didn't compile: the DSN wasn't quoted and had no semicolon, and SentrySdk needs using Sentry on .NET Framework. Drop the Web.config comment and the System.Configuration using that went with it.

Refs getsentry/sentry-dotnet#5700

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ric-oliv
ric-oliv force-pushed the docs/dotnet-aspnet-span-samples branch from 76ec5fe to 0192af5 Compare November 17, 2026 11:51
@ric-oliv
ric-oliv marked this pull request as ready for review November 17, 2026 11:51
@cursor

cursor Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Getting ready to monitor this change · Rollout details

Status Service Environment
⏳ Getting ready to monitor this change

@ric-oliv
ric-oliv requested a review from a team November 17, 2026 12:05
@ric-oliv
ric-oliv merged commit 6d3f786 into master Nov 18, 2026
33 of 34 checks passed
@ric-oliv
ric-oliv deleted the docs/dotnet-aspnet-span-samples branch November 18, 2026 12:32

This branch was successfully deployed

1 active deployment
Preview – sentry-docs — 0192af56 Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Normal Docs review has no urgent deadline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants