0
string uploadPath = "http://10.126.64.230/home/pi/Videos/";
WebClient webclient = new WebClient();
CredentialCache cc = new CredentialCache();
Uri uri = new Uri("http://10.126.64.230/pi");
NetworkCredential nc = new NetworkCredential();
nc.Domain = "root";
nc.UserName = "pi";
nc.Password = "posix";
cc.Add(
    uri,
"NTLM",
nc);
webclient.Credentials = cc;
//System.Text.Encoding.ASCII.GetString(responseArray);
bool cntrl = System.IO.File.Exists(uploadPath + this.FuplVideo.FileName);

if (cntrl)
{
    // fileName = uploadPath + this.FuplVideo.FileName + DateTime.Now.ToString("yyyy-MM-dd HHmmtt") + ext;
    // webclient.UploadFile(uploadPath, "POST", fullFilePath);
}
else
{
    webclient.UploadFile(uploadPath, "POST", fullFilePath);
}

I try to send a file to a machine that connected with LAN. But I try this code with different versions of domain, I got

"System.Net.Sockets.SocketException no connection because of target machine refused"

error every time. What do you suggest me?

Hamid Pourjam
  • 20,441
  • 9
  • 58
  • 74

1 Answers1

0

There is a chance the target machine has a firewall rule on the port you are accessing. I am guessing this is port 80. try to telnet to the remote server and see if you get a connection. if you cant connect, then it must be a firewall issue

Oladipo Olasemo
  • 2,010
  • 24
  • 31
  • I can copy a file to machine but I can not reach via code. – Yağız Muğulkoç Jun 25 '15 at 11:01
  • go to command line and try: c:/telnet 10.126.64.230 80 – Oladipo Olasemo Jun 25 '15 at 11:02
  • Yes. Clearly a firewall rule is in place. To confirm try using your browser to navigate to http://10.126.64.230/home/pi/Videos/ and see what you get. If you have fiddler you can try to connect using fiddler as well. Paste the error you get here. – Oladipo Olasemo Jun 25 '15 at 11:08
  • When I tried that machine ask me username and password. After I entered that it redirected me google with 10.126.64.230/home/pi/Videos this search. – Yağız Muğulkoç Jun 25 '15 at 11:10
  • Use that link in your browser. – Oladipo Olasemo Jun 25 '15 at 11:14
  • Yes, I tried it and it redirect me google after asking username and password. In the windows security tag "warning: this server is requesting that your username and password be sent in an insecure manner (basic authentication without a secure connection)." – Yağız Muğulkoç Jun 25 '15 at 11:15
  • "warning: this server is requesting that your username and password be sent in an insecure manner (basic authentication without a secure connection)." Browser get this warning and it redirect me to google and provide error the webpage cannot be found – Yağız Muğulkoç Jun 25 '15 at 11:22