asp.net-coreiisload-balancingf5wwwroot

asp.net core share remote or use common wwwroot among apps running behind the load balancer


I have a scenario where I'm using 2 IIS servers running on asp.net core (nopcommerce 4.10) behind the load balancer F5 with sticky session.

Since the nopcommerce doesn't support web farm at the moment, I'm looking for a work around to share the wwwroot folder between these two servers for the images/file and pondering if it's possible to create wwwroot folder somewhere else than app root path so that these 2 app can use it (which is possible if somehow I configure dotnet core app in startup.cs to use wwwroot folder from different path). Or alternatively share the wwwroot folder for both from one of these.

My current solution is to copy the file on another server when anything uploaded from admin side but this won't work with bundling.


Solution

  • The comment and answer from Robban1980 helped and I really appreciate it. Although I'm posting my final solution hoping, it will help someone, specifically for nopcommerce developer.

    I have override the method for the in FileProvider (nopcommerce uses it for accessing file resources) to take files from my folder instead of taking it from wwwroot.

    public override string GetAbsolutePath(params string[] paths)  
    {
          var allPaths = paths.ToList();
          allPaths.Insert(0, "my-folder");
          return Path.Combine(allPaths.ToArray());
    }
    

    Also, I had to set read/write file permission to the folder to make it accessible via a network