[Nessuno riesce ad aiutarmi?] Iindirizzo IP client

mercoledì 02 maggio 2007 - 09.13

fabele Profilo | Newbie

Ciao a tutti!!!
Volevo sapere come posso da una pagina ASP.net avere l'indirizzo IP del client.
Siccome io ho una rete lan e il mio computer funge da server, questa pagina risiede nella cartella C:\Inetpub\wwwroot di IIS.
Ho già provato con:

> Request.ServerVariables["REMOTE_ADDR"]
> Request.ServerVariables["HTTP_X_FORWARDED_FOR"]
> Dns.GetHostEntry(Dns.GetHostName()).AddressList
> Request.UserHostAddress

Niente di tutto ciò ha funzionato in output mi da sempre l'indirizzo ip del mio computer e non del client..COSA POSSO SCRIVERCI IN QUESTA PAGINA ASP PER AVERE QUESTO INDIRIZZO IP DEL CLIENT?

Grazie mille a tutti!!!!

trasportation Profilo | Junior Member

Il tuo client (in termini di IP) è il tuo computer come anche il tuo server è il tuo computer, cosa pensi che sia l'indirizzo IP del client??? forse ti mancano un pò di informazioni o non ti sei spiegato bene.
/*
* web: http://www.robertobeccari.it
*/

fabele Profilo | Newbie

Ciao!!Io ho due computer collegati uno è il Server e l'altro il Client...Io voglio sapere tramite la pagina ASP l'indirizzo IP del Client...
Spero di essermi spiegato meglio...Grazie mille!!!!

trasportation Profilo | Junior Member

Allora Request.ServerVariables["REMOTE_ADDR"] va più che bene, come fai a collegarti al tuo server?

http://<indirizzo ip>:<porta>/NomeApplicazione/default.aspx

metti questo codice dentro una pagina c#

foreach(string s in Request.ServerVariables)
Response.Write(s + " = " + Request[s]+"<br/>\n");

Chiama la pagina sia dal server che dal client e vedi le differenze

/*
* web: http://www.robertobeccari.it
*/

fabele Profilo | Newbie

Ciao!!!Dal mio Client mi connetto al Server così:

http://<indirizzo IP>/default.aspx

comunque domani proverò e poi ti faccio sapere....Grazie mille!!!!

fabele Profilo | Newbie

Ciao!!Ecco il risultato del client e del server (niente di buono ):

CLIENT

ALL_HTTP = HTTP_PRAGMA:no-cache HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_LANGUAGE:it HTTP_HOST:<Indirizzo IP del SERVER> HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
ALL_RAW = Pragma: no-cache Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Language: it Host: <Indirizzo IP del SERVER> User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
APPL_MD_PATH = /LM/W3SVC/1/ROOT
APPL_PHYSICAL_PATH = c:\inetpub\wwwroot\
AUTH_TYPE =
AUTH_USER =
AUTH_PASSWORD =
LOGON_USER =
REMOTE_USER =
CERT_COOKIE =
CERT_FLAGS =
CERT_ISSUER =
CERT_KEYSIZE =
CERT_SECRETKEYSIZE =
CERT_SERIALNUMBER =
CERT_SERVER_ISSUER =
CERT_SERVER_SUBJECT =
CERT_SUBJECT =
CONTENT_LENGTH = 0
CONTENT_TYPE =
GATEWAY_INTERFACE = CGI/1.1
HTTPS = off
HTTPS_KEYSIZE =
HTTPS_SECRETKEYSIZE =
HTTPS_SERVER_ISSUER =
HTTPS_SERVER_SUBJECT =
INSTANCE_ID = 1
INSTANCE_META_PATH = /LM/W3SVC/1
LOCAL_ADDR = <Indirizzo IP del SERVER>
PATH_INFO = /Login.aspx
PATH_TRANSLATED = c:\inetpub\wwwroot\Login.aspx
QUERY_STRING =
REMOTE_ADDR = <Indirizzo IP del SERVER>
REMOTE_HOST = <Indirizzo IP del SERVER>
REMOTE_PORT = 1066
REQUEST_METHOD = GET
SCRIPT_NAME = /Login.aspx
SERVER_NAME = <Indirizzo IP del SERVER>
SERVER_PORT = 80
SERVER_PORT_SECURE = 0
SERVER_PROTOCOL = HTTP/1.0
SERVER_SOFTWARE = Microsoft-IIS/5.1
URL = /Login.aspx
HTTP_PRAGMA = no-cache
HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_LANGUAGE = it
HTTP_HOST = <Indirizzo IP del SERVER>
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)

SERVER

ALL_HTTP = HTTP_CONNECTION:Keep-Alive HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:it HTTP_HOST:<Indirizzo IP del Server> HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727) HTTP_UA_CPU:x86
ALL_RAW = Connection: Keep-Alive Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Encoding: gzip, deflate Accept-Language: it Host: <Indirizzo IP del Server> User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727) UA-CPU: x86
APPL_MD_PATH = /LM/W3SVC/1/ROOT
APPL_PHYSICAL_PATH = c:\inetpub\wwwroot\
AUTH_TYPE =
AUTH_USER =
AUTH_PASSWORD =
LOGON_USER =
REMOTE_USER =
CERT_COOKIE =
CERT_FLAGS =
CERT_ISSUER =
CERT_KEYSIZE =
CERT_SECRETKEYSIZE =
CERT_SERIALNUMBER =
CERT_SERVER_ISSUER =
CERT_SERVER_SUBJECT =
CERT_SUBJECT =
CONTENT_LENGTH = 0
CONTENT_TYPE =
GATEWAY_INTERFACE = CGI/1.1
HTTPS = off
HTTPS_KEYSIZE =
HTTPS_SECRETKEYSIZE =
HTTPS_SERVER_ISSUER =
HTTPS_SERVER_SUBJECT =
INSTANCE_ID = 1
INSTANCE_META_PATH = /LM/W3SVC/1
LOCAL_ADDR = <Indirizzo IP del Server>
PATH_INFO = /Login.aspx
PATH_TRANSLATED = c:\inetpub\wwwroot\Login.aspx
QUERY_STRING =
REMOTE_ADDR = <Indirizzo IP del Server>
REMOTE_HOST = <Indirizzo IP del Server>
REMOTE_PORT = 1069
REQUEST_METHOD = GET
SCRIPT_NAME = /Login.aspx
SERVER_NAME = <Indirizzo IP del Server>
SERVER_PORT = 80
SERVER_PORT_SECURE = 0
SERVER_PROTOCOL = HTTP/1.1
SERVER_SOFTWARE = Microsoft-IIS/5.1
URL = /Login.aspx
HTTP_CONNECTION = Keep-Alive
HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_ENCODING = gzip, deflate
HTTP_ACCEPT_LANGUAGE = it
HTTP_HOST = <Indirizzo IP del Server>
HTTP_USER_AGENT = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
HTTP_UA_CPU = x86

Insomma mi da sempre lo stesso indirizzo ovunque ma quello del client non ce n'è traccia....Tu hai capito qual è il problema?
Grazie mille!!Ciao!!!

trasportation Profilo | Junior Member

esegui il comando

ipconfig

da riga di comando e delle due macchine, verifica l'indirizzo IP, non è possibile che siano uguali.

/*
* web: http://www.robertobeccari.it
*/

fabele Profilo | Newbie

L'ho già fatto l'ip è diverso...
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5