为忽略子域C#设置Cookie

时间:2018-11-19 07:33:56

标签: c# cookies web.api

我有一个网页: portal.myurl.com.au,我希望它设置一个Cookie domain=myurl.com.au,以便我可以访问files.myurl.com.au上的cookie

我正在使用Chrome作为客户端浏览器,我的C#MVC Web Api代码如下:

[Route("api/Account/Testcookie")]
        [HttpGet]
        [AllowAnonymous]
        public async Task<HttpResponseMessage> Testcookie()
        {
            HbiAuthService hbiAuthSerivce = new HbiAuthService();
            var cookieList = await hbiAuthSerivce .CreateCookie();
            var cookieHeaderList = new List<CookieHeaderValue>();
            foreach (var cookie in cookieList)
            {
                var parsedCookie = new CookieHeaderValue(cookie.Name, cookie.Value);
                parsedCookie.Domain = ".myurl.com.au"; //THIS IS BEIGN IGNORED          
                parsedCookie.Expires = cookie.Expires;
                parsedCookie.Path = cookie.Path;
                parsedCookie.Secure = cookie.Secure;
                cookieHeaderList.Add(parsedCookie);
            }
            HttpResponseMessage response = new HttpResponseMessage();
            response.Headers.AddCookies(cookieHeaderList);
            return response;
        }

在以后的浏览器中有什么改变了吗?还是艾米,我错过了一些东西

在Chrome设置中,它仍显示domain=.portal.myurl.com.au

0 个答案:

没有答案