C# 在wwwroot之外提供静态文件?

C# 在wwwroot之外提供静态文件?,c#,.net-core,C#,.net Core,下面是用于在wwwroot之外提供静态文件的代码 //在wwwroot之外提供静态文件 public static IApplicationBuilder UseClientStaticResources(this IApplicationBuilder app, HostingEnvironment env, IConfiguration Configuration, string site) { var path = Path.Combine(env.ContentR

下面是用于在wwwroot之外提供静态文件的代码 //在wwwroot之外提供静态文件

public static IApplicationBuilder UseClientStaticResources(this IApplicationBuilder app, HostingEnvironment env, IConfiguration Configuration, string site)
    {
        var path = Path.Combine(env.ContentRootPath, "sites/client1/web/assets"); // this allows for serving up contents in a folder named 'static'
        var provider = new PhysicalFileProvider(path);
        var options = new StaticFileOptions();
        options.RequestPath = ""; // an empty string will give the *appearance* of it being served up from the root
                                  //options.RequestPath = "/content"; // this will use the URL path named content, but could be any made-up name you want
        options.FileProvider = provider;
        app.UseStaticFiles(options);
        return app;
    }
    public static IApplicationBuilder UseTemplateStaticResources(this IApplicationBuilder app, HostingEnvironment env, IConfiguration Configuration, string template)
    {
        var path = Path.Combine(env.ContentRootPath, "sites/_templates/template1/web/assets"); // this allows for serving up contents in a folder named 'static'
        var provider = new PhysicalFileProvider(path);
        var options = new StaticFileOptions();
        options.RequestPath = ""; // an empty string will give the *appearance* of it being served up from the root
                                  //options.RequestPath = "/content"; // this will use the URL path named content, but could be any made-up name you want
        options.FileProvider = provider;
        app.UseStaticFiles(options);
        return app;
    }
在appsettings.json中,我们定义的结构如下

"Multitenancy": {
   "Tenants": [
     {
       "client": "client1",
       "host": "localhost:5000"
     },
     {
       "client": "client2",
       "host": "localhost:6000"
     }
   ]
 }
和使用

string client = context.ActionContext.HttpContext.GetTenant<AppTenant>()?.client;
string client=context.ActionContext.HttpContext.GetTenant()?.client;
我试图根据我们在UseClientStaticResources/UseTemplateStaticResources扩展方法中浏览的主机URL获取“client1”或“client2”

如何使用SaasKit获取此文件中的租户信息


这是否可能获取此场景中的上下文?

并且不起作用
这是什么意思?现在检查一下@Chetan ranpariyas,是否有错误?你期望的价值是什么?你实际得到的价值是什么?此代码在哪里
string client=context.ActionContext….
writed?说明已编辑