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

1 minute read

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()

Fix:

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

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.

Leave a comment