Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 子域缓存_Asp.net_Caching - Fatal编程技术网

Asp.net 子域缓存

Asp.net 子域缓存,asp.net,caching,Asp.net,Caching,有子域:sub1.domain.ru、sub2.domain.ru、sub3.domain.ru、sub4.domain.ru。在默认页面上有一个代码: protected void Page_Load(object sender, EventArgs e) { string subdomain = Cache[key] as string; if (subdomain != null) { Label1.Text = "Your subdomain is

有子域:sub1.domain.ru、sub2.domain.ru、sub3.domain.ru、sub4.domain.ru。在默认页面上有一个代码:

protected void Page_Load(object sender, EventArgs e)
{
    string subdomain = Cache[key] as string;
    if (subdomain != null)
    {
        Label1.Text = "Your subdomain is :" + subdomain;
    }
    else
    {
        Cache[key] = GetSubDomainName();
        Label1.Text = "Your subdomain is :" + Cache[key] as string;
    }
}

用户是否会在不同的子域(sub1.domain.ru、sub2.domain.ru、sub3.domain.ru、sub4.domain.ru)中看到自己的子域名?

,但我认为缓存是全局的。您应该使用会话来代替

如果你这样做

cache["subdomain"] = getMySubDomain()
它每次都会被覆盖,如果你这样做了

dim sd as string = cache["subdomain"]
它将为您提供独立于当前登录用户的上次保存的子域


为什么不尝试使用不同的浏览器。

如果我可以重新表述这个问题,我想你是在问,与页面所在的应用程序关联的
缓存对象是否跨子域共享

答案是,这取决于:

  • 如果每个子域都部署为 不同的AppDomain,它们将具有 它们自己的内存空间(缓存会话将不被共享)。注意:即使他们共享同一个应用程序池,这也是正确的

  • 如果您将此设置为单个 AppDomain接受多个主机头, 那么就有可能访问这个 不同子域下的页面,但 访问缓存的一个副本 按所有要求


对于
else
,存在
if
。我调整了格式以使其更清晰。getsubdomainname()是一个自定义方法。这只是一个例子。