在我的客户端(MVC 应用程序的控制器)中,我使用下面的代码来设置 cookie 值:
HttpCookie cookie = new HttpCookie("TestCookie");
cookie.value = 'Test';
HttpContext.Request.Cookies.Add(cookie);
我还在请求标头中设置 cookie 值。这是在我配置微风实体管理器时完成的。我使用微风查询从 web api 获取数据。
'Cookie': UserProfileID = config.getCookies('UserProfileID')
但是在 Web API 中,我总是发现请求标头中没有 cookie。
request.Headers.GetCookies("UserProfileID").FirstOrDefault()