I get this error on HttpContext, when I try to get the server Name
httpcontext is not declared it may be inaccessible due to its protection level
Dim strServerName As String = If((HttpContext.Current IsNot Nothing), HttpContext.Current.Request.ServerVariables("LOCAL_ADDR").ToString(), Environment.MachineName)
BTW I believe your approach won't work. A common catch is to try code that seems to work because your machine is both the web server and on the browser side. On a real web server it would give the name of the web server and I think you rather try to get
the IP / machine name of the client machine ?
Member
18 Points
41 Posts
httpcontext - Access issue
Mar 28, 2019 01:17 PM|mansooraabid|LINK
How do I resolve this
I get this error on HttpContext, when I try to get the server Name
httpcontext is not declared it may be inaccessible due to its protection level
Dim strServerName As String = If((HttpContext.Current IsNot Nothing), HttpContext.Current.Request.ServerVariables("LOCAL_ADDR").ToString(), Environment.MachineName)
All-Star
48720 Points
18184 Posts
Re: httpcontext - Access issue
Mar 28, 2019 01:33 PM|PatriceSc|LINK
Hi,
Which message you have if using the full name ie System.Web.HttpContext.Current ? Uou may need Imports System.Web to bing the correct namespace in scope. See https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/program-structure/namespaces
BTW I believe your approach won't work. A common catch is to try code that seems to work because your machine is both the web server and on the browser side. On a real web server it would give the name of the web server and I think you rather try to get the IP / machine name of the client machine ?