简体   繁体   English

Asp.Net Cookie共享

[英]Asp.Net Cookie sharing

This is C#.Net code: 这是C#.Net代码:

How to share Cookie between 2 HttpWebRequest calls? 如何在2个HttpWebRequest调用之间共享Cookie?

Details: 细节:

I am posting a form in first request from abc.com to xyz.com , this form contains some setting variables which are used by the system. 我正在从abc.comxyz.com的第一个请求中发布表单,该表单包含一些系统使用的设置变量。 lets say there is a input field in the form which sets the size of grid pages to be displayed in other pages. 可以说表单中有一个输入字段,用于设置要在其他页面中显示的网格页面的大小。

Once i have updated the setings in previous request, i go to send a request to another page which shows off asp.net gridview/grid. 一旦更新了先前请求中的设置,我便将请求发送到另一个页面,该页面显示了asp.net gridview / grid。 The grid might contaian several pages and the page size should be the one which i set in previous request. 网格可能包含几个页面,并且页面大小应该是我在上一个请求中设置的页面大小。 But when i do this via HttpWebReeust it does not happen. 但是当我通过HttpWebReeust执行此操作时,它不会发生。

When i do it via browser, loading the setting page in the browser and then going to the grid view page... i see the page size is updated. 当我通过浏览器执行此操作时,将设置页面加载到浏览器中,然后转到网格视图页面...我看到页面大小已更新。

I want to achieve this via code. 我想通过代码实现这一目标。 Sicne i am scraping this grid. 希恩,我正在刮这个网格。 i have to set page size or visit the gird pages one by one via code. 我必须设置页面大小或通过代码一张一张地访问gird页面。

Or is it possible to set a cookie on 2nd request which is used to set in first request? 还是可以在第二个请求中设置用于在第一个请求中设置的Cookie? It will be great if i go this way. 如果我这样走,那就太好了。 any solution? 有什么办法吗? All posts go to xyz.com from abc.com. 所有帖子都从abc.com转到xyz.com。

Cookies are controlled by your browser. Cookies由您的浏览器控制。 If you were to open the same page in two different browsers, you will not see the cookies set by one browser in another. 如果要在两个不同的浏览器中打开同一页面,则不会看到一个浏览器在另一个浏览器中设置的cookie。

HTTPWebRequest does not use any browser, so I don't think it will set any cookie at all. HTTPWebRequest不使用任何浏览器,因此我认为它根本不会设置任何cookie。

You would probably need to store the settings at server side, maybe use a session. 您可能需要将设置存储在服务器端,或者使用会话。

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

相关问题 ASP.NET站点身份验证Cookie共享 - ASP.NET Site Authentication Cookie sharing ASP.NET站点无意中共享登录cookie - ASP.NET sites unintentionally sharing login cookie 在两个ASP.NET MVC应用程序之间共享Cookie - Sharing cookie between two asp.net mvc applications 通过cookie共享ASP.NET webforms和MVC身份验证 - ASP.NET webforms and MVC authentication sharing via cookie 在子域中跨ASP.NET共享ASP.NET 5中的身份验证Cookie - Sharing Authentication Cookie in ASP.NET 5 across subdomains 单独的应用程序共享相同的ASP.Net会话Cookie - Separate Applications Sharing the Same ASP.Net Session Cookie 与asp.net core 2.0共享asp.net 4表单身份验证cookie - sharing asp.net 4 forms authentication cookie with asp.net core 2.0 使用ASP Classic对ASP.NET会话共享解决方案设置Cookie到期 - Setting cookie expiration with ASP classic to ASP.NET session sharing solution ASP WebForms 和 ASP.NET Core MVC 应用程序之间的身份验证 cookie 共享 - Authentication cookie sharing between ASP WebForms and ASP.NET Core MVC app 跨默认域(* .azurewebsites.net)上的Azure Web应用程序的ASP.NET Core共享身份Cookie - ASP.NET Core Sharing Identity Cookie across azure web apps on default domain (*.azurewebsites.net)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM