Adding multiple Set-Cookie Headers in ASP.NET Web

前端 未结 2 2035
情歌与酒
情歌与酒 2020-12-05 09:58

I faced a problem.

When you add multiple Set-Cookie headers to the response

headers.Add(\"Set-Cookie\", \"a=b;Path=/;\");
headers.Ad         


        
2条回答
  •  长情又很酷
    2020-12-05 10:07

    You can use the HttpContext.Current.Response.SetCookie

    using System.Web;
    
    
    HttpCookie foo = new HttpCookie("foo", "true");
    HttpContext.Current.Response.Cookies.Add(foo); 
    
    HttpCookie bar = new HttpCookie("bar", "true");
    HttpContext.Current.Response.Cookies.Add(bar);
    

    This will add multiple set-cookies header in the response.

    Edit: also, you should add the

    
    

    in your web.config

提交回复
热议问题