For some reason, you may need to place a cms-content directory on a network share. If you are a developer and run the storefront in debugging or as a console application, you will not have any problems with this. Just your current user should have access to this network resource. But if your application hosts into IIS, access problems to network resource may occur.
In both cases, it is recommended to use the UNC path to the folder in the appsettings.json file. Do not use mapped drive! This causes performance issues.
Also be careful. The UNC path must be specified with an escaped slash character.
For example:
“ContentConnectionString”: “provider=LocalStorage;rootPath=\\server\shared\cms-content”
In ASP.NET, developers are able to use a virtual directory within IIS website for storing static resources in the directory outside of the application, including on a network resource. Unfortunately, with ASP.NET Core, this solution doesn’t work. A virtual directory in IIS won’t be recognized and users will see a 404 error. Kestrel runs beneath IIS (using the HttpPlatformHandler module) and IIS brokers only the requests to it, so Kestrel does not know about virtual directories from IIS.
The solution to access this folder is to run the webserver’s AppPool as the identity that can access the share. This way is safer because the credentials are stored securely in the IIS config (rather than in code or in config files). For this, you just need to create a local user on both machines and ensure they both have the same name and password. You can also use Active Directory Domain Account, just make sure, that you correctly type in the name and domain. So, the full instruction is as follows,
- On your IIS machine, create a user and set a password.
- On your network share machine, create a user with the same name and password as in step 1.
- Give permission to a shared folder to this user.
- In IIS Manager, select the application pool that your web app uses or create a new one if you use the default one.
- Click on “Advanced Settings” in the right Actions bar. Under Process Model, click on the “Identity” value and select “Custom account”.
- Click on the “Edit” and enter user name and password from step 1. If you enter all information correctly, the pop-up will be closed successfully without any error messages.
- After that stop your Web Site.
- Back again to your application pool and click on the “Recycle”.
- Start your Storefront Web Site.