In one ASP.NET MVC app on a domain "mysite.com", I'm writing a cookie to a specific domain, say ".mysite.com". I'm able to confirm that the browser accepts my cookie.
Then, from another ASP.NET MVC app, say "jmp.mysite.com", I'm trying to read the cookie set by the first app.
The problem? Well, I can't read the开发者_开发百科 cookie. My browser says it's there, but my web server says it isn't.
Is there some special way of reading these sorts of cookies? Could IIS perhaps not be sending them to ASP.NET?
To create the cookie from foo.mysite.com
:
public ActionResult Index()
{
var cookie = new HttpCookie("foo", "bar")
{
HttpOnly = true,
Domain = "mysite.com"
};
return View();
}
and to read the cookie from jmp.mysite.com
:
public ActionResult Index()
{
var cookie = Request.Cookies["foo"];
if (cookie != null)
{
var value = cookie.Value;
// TODO: do something with the value
}
return View();
}
精彩评论