0

enter image description here

I getting this error and I have no clue why I am pretty new to asp.net core so if you could take it easy on me that would be great.

 string port = System.Web.HttpContext.Current.Request.ServerVariables["SERVER_PORT"];

ERROR: Severity Code Description Project File Line Suppression State Error CS0234 The type or namespace name 'HttpContext' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) Elearn C:\Users\source\elearn2Fin\Elearn\Elearn\Program.cs 29 Active

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
  • It looks like you're trying to access the request context outside the context of a request (you're trying to access it in `Program`). – ProgrammingLlama Jun 11 '21 at 18:17
  • By the way, your question title is a double negative (you're asking why it _is_ working). – ProgrammingLlama Jun 11 '21 at 18:17
  • @Llama haha I saw I fixed the title. i really need to use the Web.HttpContext.Current.Request in the program is there any other way i can get the URL/domain of my site inside the program file? – AverageGuyIsaac Jun 11 '21 at 18:22

0 Answers0