Sowmya Sirsi

Sowmya Sirsi

  • NA
  • 173
  • 45.4k

HttpContext does not contain a definition for Current

Jul 9 2021 4:44 AM

Hi Team,

I am getting an error as " HttpContext does not contain a definition for Current"

 

      private string ClientIP()
        {
          
            string ipAddress = string.Empty;
            try
            {
                string strHostName = HttpContext.Current.Request.UserHostAddress.ToString();
                ipAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
            }
            catch (Exception ex)
            {
                
            }
            finally
            {
               
            }
            return ipAddress;
        }

 

Please assist me as what need to be added instead of Current ?

 


Answers (6)