Asp.net mvc 3 MVC cookie路径不工作

Asp.net mvc 3 MVC cookie路径不工作,asp.net-mvc-3,cookies,Asp.net Mvc 3,Cookies,我正在尝试设置如下cookie路径: public class HomeController : Controller { public ActionResult Index() { ControllerContext.HttpContext.Response.Cookies.Add( new HttpCookie("test", "hello") { Path = @"/admin", Expires = D

我正在尝试设置如下cookie路径:

public class HomeController : Controller
{
    public ActionResult Index()
    {
        ControllerContext.HttpContext.Response.Cookies.Add(
             new HttpCookie("test", "hello") { Path = @"/admin", 
             Expires = DateTime.Now.AddDays(1)});

        return RedirectToAction("About", "Admin");
    }
}

public class AdminController : Controller
{
    public ActionResult About()
    {
        var cookieCount = HttpContext.Request.Cookies.Count;
        return View();
    }
}
当索引操作重定向到Admin/About操作时,cookie不会被检索,cookieCount为零

如果我将cokie路径更改为“/”,则cookieCount设置为1时工作正常


我做错了什么?

它区分大小写。因此,如果重定向到
/Admin/About
,请尝试:
Path=@”/Admin“
。或者使用小写URL。

天哪,你说得太对了。我把cookie路径改为Admin,它成功了。非常蹩脚。