Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.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 如何在Azure网站部署槽中使用通配符子域?_Asp.net_Session_Cookies_Azure Web App Service_Wildcard Subdomain - Fatal编程技术网

Asp.net 如何在Azure网站部署槽中使用通配符子域?

Asp.net 如何在Azure网站部署槽中使用通配符子域?,asp.net,session,cookies,azure-web-app-service,wildcard-subdomain,Asp.net,Session,Cookies,Azure Web App Service,Wildcard Subdomain,我真的很喜欢用Azure网站的部署槽功能交换发布管理。但我不确定是否将其用于我当前的配置 我的站点中有通配符子域,用户的已验证会话将在根域和任何子域中持久化。为了实现这一点,我必须在web.config中为我的cookie指定域,例如domain=“.mysite.com”。我认为一切正常。接下来我要做的就是让它在我不同的构建环境(开发、登台、生产)下工作。我通过使用web.config转换实现了这一点。因此,如果它是web.config(debug)转换,那么我的身份验证cookie被指定为d

我真的很喜欢用Azure网站的部署槽功能交换发布管理。但我不确定是否将其用于我当前的配置

我的站点中有通配符子域,用户的已验证会话将在根域和任何子域中持久化。为了实现这一点,我必须在web.config中为我的cookie指定域,例如domain=“.mysite.com”。我认为一切正常。接下来我要做的就是让它在我不同的构建环境(开发、登台、生产)下工作。我通过使用web.config转换实现了这一点。因此,如果它是web.config(debug)转换,那么我的身份验证cookie被指定为domain=“mysite-dev.com”,或者如果它是web.config(release),那么它是domain=“mysite.com”

以下是我当前的配置:

Dev Build-web.config(调试)


生产构建-web.config(发布版)


问题1:

如何在Azure登台环境中测试通配符子域并维护经过身份验证的会话?因为当认证cookie的生产配置为cookie domain=“example.com”时,认证cookie将无法在登台环境中正常工作,而应该将其设置为domain=“example staging.com”。我能想到的唯一一件事就是创建web.config(staging)build,但一旦我将staging slot切换到生产,就会中断生产

问题2:

您可以将自己的自定义域绑定到默认的Azure登台URL吗?因此,我可以使用example-staging.com代替example-staging.azurewebsites.net。我这样问是因为Azure在其默认应用程序url上似乎不支持多个级别的子域。例如,您不能执行subdomain.example.azurewebsites.net。因此,我能想到的实现这一点的唯一方法是将我自己的自定义域绑定到staging部署槽,这样我就可以执行subdomain.example-staging.com

有人处理过类似的情况吗

  <system.web>
    <authentication mode="Forms">
      <forms name="FormsAuth" loginUrl="http://example-dev.com/Login.aspx" defaultUrl="http://example-dev.com" domain=".example-dev.com" />
    </authentication>
<httpCookies domain="example-dev.com" />
</system.web>
<system.identityModel.services>
    <federationConfiguration>
      <cookieHandler name="MySite" domain=".example-dev.com" requireSsl="false" />
    </federationConfiguration>
  </system.identityModel.services>
  <system.web>
    <authentication mode="Forms">
      <forms name="FormsAuth" loginUrl="http://example.com/Login.aspx" defaultUrl="http://example.com" domain=".example.com" />
    </authentication>
<httpCookies domain="example.com" />
</system.web>
<system.identityModel.services>
    <federationConfiguration>
      <cookieHandler name="MySite" domain=".example.com" requireSsl="false" />
    </federationConfiguration>
  </system.identityModel.services>