1
我已啓用與剃刀的應用程序沒有設置和這樣的服務:ServiceStack Cookie的瀏覽器
public object Post(SelectTerminalRequest request)
{
var location = base.Request.AbsoluteUri.CombineWith(request.TerminalId, "/flights");
if (Request.Cookies.ContainsKey("Terminal"))
{
Request.Cookies.Remove("Terminal");
}
Request.Cookies.Add("Terminal",
new Cookie("Terminal", request.TerminalId.ToString())
{ Expires = DateTime.Now.AddYears(1) });
return new HttpResult(HttpStatusCode.Redirect)
{
Location = location
};
}
然而,當我嘗試訪問該cookie在我的Razor視圖,其空:
@{
Cookie cookie;
Request.Cookies.TryGetValue("Terminal", out cookie);
var baseUri = Request.GetApplicationUrl() + "/terminals";
var redirectUrl = cookie != null ? baseUri + "/" + cookie.Value + "/flights" : baseUri;
}
當我瀏覽了我的餅乾,我沒有看到任何與Terminal
: