DEV Community

CodetoLive blog
CodetoLive blog

Posted on • Originally published at codetolive.in on

IHeaderDictionary does not contain a definition for Referrer and no accessible extension method Referrer accepting a first...

1. Problem statement

‘IHeaderDictionary’ does not contain a definition for ‘Referrer’ and no accessible extension method ‘Referrer’ accepting a first argument of type ‘IHeaderDictionary’ could be found (are you missing a using directive or an assembly reference?

Referrer is missing in the ‘IHeaderDictionary’ when using the .NET Core or .NET projects.

2. Context

A request header is an HTTP header that can be used in the HTTP request to pass additional information. The header can be sent from the client, and the same can be read from the server to retrieve the information.

The way of reading the header has been changed in the .NET Core and .NET projects.

3. Solution

Existing code:

Request.Headers.Referrer.ToString()

Enter fullscreen mode Exit fullscreen mode

Fix:

Request.Headers["Referrer"].ToString();

Enter fullscreen mode Exit fullscreen mode

Thanks for reading the article on fixing the request header issue in an ASP.NET Core project. Please feel free to drop your comments below, and you can follow us on Twitter (@Codetoliveblog) to receive the latest updates from this blog.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay