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.

Top comments (0)