I created classes, which should collect information about user, but when I am referencing that class its give me an error:
Here is my class:
PublicClass clientConnectInfo
Inherits System.Web.UI.UserControl
PublicFunction getIpAddress()AsString
Return Request.ServerVariables("REMOTE_ADDR")
EndFunction
EndClass
That how I am referencing:
Dim clientInfoAsNew clientConnectInfo
Dim ipAddressAsString = clientInfo.getIpAddress
Error:
Object reference not set to an instance of an object.
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
|
Return HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
It workded! Thank you very much!
0 comments:
Post a Comment