Skip to content

Sentry SDK is overwriting the User.IpAddress on ASP.NET #3337

@nicholashead

Description

@nicholashead

Package

Sentry

.NET Flavor

.NET

.NET Version

4.7.2

OS

Windows

SDK Version

4.4.0

Self-Hosted Sentry Version

No response

Steps to Reproduce

  1. Set SendDefaultPii to true during SentrySdk.Init call
  2. Create new SentryEvent - and set the event's User.IpAddress to a specific value.
  3. Call SentrySdk.CaptureEvent and pass in the event.

Expected Result

The Sentry dashboard should show the User's IP as the one we set.

Actual Result

It appears to always contain an internal/server IP instead. I believe this may be because of this code?

@event.User.IpAddress = context.Request.UserHostAddress;

But I am honestly not certain.

If I am doing something wrong here, would love guidance. But we have our own logic that fires off before a Sentry event sends - and if it's inside a web requests - gets the current user context (who's logged in) and IP address data, then stamps it onto the SentryEvent. We get the IP address ourselves because we're parsing CloudFlare/proxy IPs in the HTTP headers.

Metadata

Metadata

Assignees

Projects

Status

Done

Status

No status

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions