简体   繁体   English

Window.Open杀死会话和Cookie

[英]Window.Open Killing Session and Cookies

I am trying to open a new window from code behind when the user clicks on a link button, but my application cookies and session is killed as user cannot do anything on the request page but i can see the window correctly with the response URL. 我试图在用户单击链接按钮时从背后的代码打开一个新窗口,但是由于用户无法在请求页面上执行任何操作,所以我的应用程序cookie和会话被杀死,但是我可以正确显示带有响应URL的窗口。 Why is this happening and during the response I am not doing anything with the cookies. 为什么会发生这种情况,并且在响应过程中,我没有对Cookie进行任何操作。 I was using the following post Response.Redirect to new window 我正在使用以下帖子Response.Redirect到新窗口

        string url = "XYZ"
        string target = "";
        string windowFeatures = "menubar=0,scrollbars=1,width=780,height=900,top=10";
        script = @"window.open(""{0}"", ""{1}"", ""{2}"");";
        script = String.Format(script, url, target, windowFeatures);
        ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);

Your session is actually stored in an asp.net cookie, so that makes me think your cookies aren't valid in the new window. 您的会话实际上存储在asp.net cookie中,因此让我认为您的cookie在新窗口中无效。

For some reason, is your URL different? 由于某些原因,您的网址是否不同? Cookies aren't shared across domains, so if your main app is at "123.com" and your new window is at "XYZ.com", they won't have access to each other's cookies. Cookie不会跨域共享,因此,如果您的主应用程序位于“ 123.com”,而新窗口位于“ XYZ.com”,则它们将无法访问彼此的Cookie。 That means no session, etc. 那意味着没有会话,等等。

If you're not on different domains, then there is something else happening (specific code) that's wiping out your cookies. 如果您不在不同的域中,则发生了其他事情(特定代码),这些事件会清除Cookie。 For example, if for some reason, your new window is opening in a different browser (which would take some interesting code) or if your browser is wiping cookies. 例如,如果由于某种原因,您的新窗口正在其他浏览器中打开(需要一些有趣的代码),或者您的浏览器正在擦除Cookie。

If you need more help, post more of the code so we can get more context. 如果您需要更多帮助,请发布更多代码,以便我们获得更多上下文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM