I have a cookie that holds a tmp file name for backend processing.
try {
var cookie = new HttpCookie("TargetExcelFile") {
Name = "TargetExcelFile",
Path = "/",
Secure = true,
Expires = DateTime.Now.AddDays(1d),
Value = file
};
Response.Cookies.Add(cookie);
} catch (Exception e) {
throw new Exception("Create file cookie failed: " + e.Message);
}
In production it works fine but on localhost
the value in the browser is blank. I can set breakpoints and see that the cookie has a value in both cases at the Response.Cookies.Add(cookie);
line.
When run on localhost
the cookie is created but with no value in the browser.
I had the thought that the Secure
flag might be an issue on localhost
so I did the following:
try {
var cookie = new HttpCookie("TargetExcelFile") {
Name = "TargetExcelFile",
Path = "/",
#if DEBUG
Secure = false,
#else
Secure = true,
#endif
Expires = DateTime.Now.AddDays(1d),
Value = file
};
Response.Cookies.Add(cookie);
} catch (Exception e) {
throw new Exception("Create file cookie failed: " + e.Message);
}
... it didn't help.
Ideas?