是否有可能访问的cookie它存在于IIS中的其他应用程序? [英] Is it possible to access cookies which exists on another application in IIS?

查看:136
本文介绍了是否有可能访问的cookie它存在于IIS中的其他应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个网站上我的IIS7,我可以把同一域中对他们俩的,我想这两个应用程序的一些饼干给他们之间可以共享,所以比我可以从其中的一个创建的cookie,并从阅读另外一个,这可能吗?我是否需要任何自定义配置,这样做吗?

I have 2 website on my IIS7, I can put the same domain for both of them, I want some cookies of both applications to be shared between them, so than I can create the cookie from one of them and read it from the other one, is that possible? do I need any custom configurations to do that?

请注意:我的网站,1是asp.net网站的形式,另一种是MVC

note: My websites, 1 is asp.net forms website and the other is MVC.

推荐答案

在创建的cookie指定域:

When you create the cookie specify the domain:

var cookie = new HttpCookie("foo", "bar")
{
    // indicates that only server side scripts can read this cookie
    HttpOnly = true,

    // indicates that the cookie will be available throughout the entire domain
    Domain = "example.com"
};
Response.AppendCookie(cookie);

现在在其他应用程序,你将能够访问这个cookie(假设当然是在同一个域中运行):

Now on the other application you will be able to access this cookie (assuming of course it is running on the same domain):

var cookie = Request.Cookies["foo"];

这篇关于是否有可能访问的cookie它存在于IIS中的其他应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆