【发布时间】:2022-08-19 18:53:22
【问题描述】:
我创建了一个 Web 应用程序,当我在普通浏览器窗口中运行应用程序时,它运行良好。但是当我在 iFrame 标签中打开相同的应用程序时,我的 cookie 会自动消失。
当我检查浏览器窗口时,我可以看到 cookie 和会话,但它不起作用。 enter image description here
标签: c# asp.net asp.net-mvc
我创建了一个 Web 应用程序,当我在普通浏览器窗口中运行应用程序时,它运行良好。但是当我在 iFrame 标签中打开相同的应用程序时,我的 cookie 会自动消失。
当我检查浏览器窗口时,我可以看到 cookie 和会话,但它不起作用。 enter image description here
标签: c# asp.net asp.net-mvc
这可能是因为您没有在 web.config 上设置域
有时您在域上调用 iframe 时没有 www.,这设置的 cookie 与您拥有 www. 时不同
依此类推web.config 在需要的地方设置domain,例如:
<authentication mode="Forms">
<forms domain="local.com" />
</authentication>
<httpCookies domain="local.com" />
【讨论】:
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?
【讨论】: