【问题标题】:C# Application, Cookies not set when we open application through iFrame tagC#应用程序,当我们通过iFrame标签打开应用程序时没有设置Cookies
【发布时间】:2022-08-19 18:53:22
【问题描述】:

我创建了一个 Web 应用程序,当我在普通浏览器窗口中运行应用程序时,它运行良好。但是当我在 iFrame 标签中打开相同的应用程序时,我的 cookie 会自动消失。

当我检查浏览器窗口时,我可以看到 cookie 和会话,但它不起作用。 enter image description here

    标签: c# asp.net asp.net-mvc


    【解决方案1】:

    这可能是因为您没有在 web.config 上设置域

    有时您在域上调用 iframe 时没有 www.,这设置的 cookie 与您拥有 www. 时不同

    依此类推web.config 在需要的地方设置domain,例如:

    <authentication mode="Forms">
      <forms domain="local.com" />
    </authentication>
    
    <httpCookies domain="local.com" />
    

    【讨论】:

    • 我在 web.config 文件中添加了下面的配置
    • <sessionState mode="InProc" timeout="500" cookieSameSite="None"/> <httpCookies httpOnlyCookies="true" requireSSL="true" domain="local.com"/> <authentication mode="Forms"> <forms loginUrl="~/Auth" timeout="500" slipExpiration="true" domain="local.com"/> </authentication>
    【解决方案2】:
    I have added below config in web.config file 
    
     <sessionState mode="InProc" timeout="500" cookieSameSite="None"/> 
            <httpCookies httpOnlyCookies="true" requireSSL="true" domain="local.com"/>
            <authentication mode="Forms">
                <forms loginUrl="~/Auth" timeout="500" slidingExpiration="true" domain="local.com"/> 
            </authentication>
    
    But still cookies not set. Could you please assist?
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-29
      • 1970-01-01
      • 2014-10-29
      • 1970-01-01
      • 2019-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多