System.IO.IOException: The user name or password is incorrect

0

I have an ASP.NET application, which is an ASP.NET application, where I need to access a directory and check files and sometimes move and delete them. In my micro it worked perfectly, however when uploading the application on the IIS server it started to return the error System.IO.IOException: The user name or password is incorrect. . I have accessed the server and logged in to the directory that I need to access, and I have given permission for the IUSR user (for everyone) to be able to access, but I still receive the error message. Is there any way to log in to the application in the directory by passing user and password or can access the directory in some other way?

Note: The microphone I'm trying to access is not in the same domain as my server and unfortunately I can not put them in the same domain.

    
asked by anonymous 28.02.2018 / 19:28

2 answers

0

This happens because the username on which the app is running on the production machine does not have access on the other server, giving exception.

It probably ran locally because the user running the local machine has access to this remote server, giving no error.

    
28.02.2018 / 20:17
0

Good Night,

Try the following piece of code:

using (var networkCon = new NetworkConnection(destinationFolder, New NetworkCredential(username, password))
{
    File.ReadAllText(destinationFolder + "Teste.txt");
}
    
01.03.2018 / 22:07