In my app, I am dropping a new folder and a set of files into my directory whenever a new hosting client has been created using code:
Directory.CreateDirectory("MyClient", ...);
file.CopyTo("MyClient", ...);
the folders are like this example:
- www.MyDomain.com/MyClient
- www.MyDomain.com/MyClient/Default.cshtml
- www.MyDomain.com/MyClient/js/default.js
- www.MyDomain.com/MyClient/img/default.png
...and so on
Now if you visit the MyClient
path, you would expect it to load Default.cshtml
, but instead you will get a 404 page not found. Until you restart the hosting, then if you visit the same path again you get the correct Default.cshtml
page content.
If I understand it correctly, SS builds the mvc folder paths only at startup, then it will not automatically add new folders until you restart your hosting?
Is there a way to make SS be aware of the folder structure changes?
ServiceStack creates a static cache of top-level files and directories which is stored in the private static HttpHandlerFactory.WebHostRootFileNames
(in lowercase).
One approach is to use Reflection to add your new top-level myclient
folder to the private collection. An alternative approach is to upload files/folders under an existing top-level folder, e.g:
/clients/MyClient
Nested files/folders are not cached so can be added and accessed after the AppDomain has started.