简体   繁体   中英

Unable to write IIS hosted application to a shared folder in Ubuntu but no problem with IISExpress

I have a shared folder (assets) in the Ubuntu machine and ASP.NET MVC application in a Windows machine. Both machines are in the same network and I have to save files in the shared folder in Ubuntu from the MVC application. When I run the application in IISExpress , the application saves the files without any error. But when I host the application in IIS , it gives me an error.

The specified server cannot perform the requested operation.

Here is the code I am using to save the files.

  try
            {
                string sourceFile = @"D:\myfile.pdf";

                string destinationPath = @"\\ubuntu\assets/";

                byte[] fileBytes = System.IO.File.ReadAllBytes(sourceFile);

                System.IO.File.WriteAllBytes(destinationPath + Guid.NewGuid().ToString() + ".pdf", fileBytes);
            }
            catch (Exception ex)
            {

            }

I played with Identity in Application Pool in IIS to LocalSystem, NetworkService. Any thoughts on how to achieve this goal?

One way I achieve this is as below:

  1. Go to the particular Application Pools and click on Advanced Settings .
  2. Click on Identity and click on Custom account and click on Set…
  3. Put window's current login User name , Password and Confirm password.
  4. Click OK and recycle the Application pool by right-clicking and clicking on Recycle .

I don't know if it is the right way to doing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM