6
Answers

HttpContext does not contain a definition for Current

Sowmya Sirsi

Sowmya Sirsi

3y
21.4k
1

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)