HttpContext.Current.Request.ServerVariables

0
0

Hi,

I am migrating a VWGui app to Wisej. I am having a problem with HttpContext.Current as it returns null. I have tried to use HttpRequest.ServerVariables but had no success as it gave me an error “An object reference is required for the non-static field method or property”. Is there any way I can do this in Wisej?

public static string GetIP()
{
try
{
string strIpAddress = System.Web.HttpContext.Current.Request.ServerVariables[whateverstring];

if (strIpAddress == null) strIpAddress = System.Web.HttpContext.Current.Request.ServerVariables[whateverstring];
if (strIpAddress == null) strIpAddress = System.Web.HttpContext.Current.Request.UserHostAddress;
if (strIpAddress == null) strIpAddress = “someip”;
return strIpAddress;
}
catch
{
return “someip”;
}
}

 

  • You must to post comments
0
0

Great, thanks Frank and sorry for bothering you. I still have one question: is there any replacement for “HTTP_X_FORWARDED_FOR”?

  • Frank (ITG)
    It depends. Maybe Application.ServerVariables[“REMOTE_ADDR”] can be a replacement. Best regards, Frank
  • You must to post comments
1
0

Hi Ezequiel,

this can be found by a simple search for Server Variables at docs.wisej.com

Here you find this:
https://docs.wisej.com/docs/controls/general/application#server-variables

Best regards
Frank

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.