The error is this:
Severity Code Description Project File Line Suppression State Error CS1061 'HttpRequest' does not contain a definition for 'ServerVariables' and no accessible extension method 'ServerVariables' accepting a first argument of type 'HttpRequest' could be found (are you missing a using directive or an assembly reference?) Elearn C:\Users\Isaac Bredbenner\source\repos\Elearm_Finalchanges\Elearn\Elearn\Controllers\AccountController.cs 161 Active
[HttpPost]
public IActionResult CookieConsents()
{
CookieConsents cookieConsents = new CookieConsents
{
Consent = true,
IpAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"],
ConsentReceivedOn = DateTime.Now
};
_elearnContext.CookieConsents.Add(cookieConsents);
_elearnContext.SaveChanges();
return View();
}
I have been trying to research this error and I found a form that was telling me to install a package but even after installing it on the visual studio I am getting this error. my file imports are as follows:
using DAL.Context;
using DAL.Models;
using DAL.Resources;
using Elearn.Helpers;
using Elearn.Infrastructure;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Localization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using System.Web;
using X.PagedList;
Do I need to be using httpRequest or something along those lines? please let me know if anyone has any ideas on what the root of my problem is.