Sowmya Sirsi

Sowmya Sirsi

  • 1.9k
  • 128
  • 3.6k

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)