c# - ASP.NET MVC 5 - Cookies being not created -


I'm getting my controller action which calls a private method that handles cookies. The problem is that the cookie is at all Not being made. I have read many posts but I did not get any response because I think that my handling cookies are correct in this code.

Any web? What is the config setting that I have to check in relation to cookies? I also tried different browsers

I debug the code and I can see that the cookie is actually set in the code but the cookie is not there when I load the page and keep an eye on the cookies .

  Personal ABHomeModel Handle Whitebox (ABHomeModel Model) {var white box = _whiteBoxService.GetActiveWhiteBox (); If (model.WhiteBox! = Null) {const string cookieName = "whitebox"; Var white box cookie = http constance. request. Cookies (Cookies); If (whiteBoxCookie! = Null) {var Display Times = Convert. ToInt32 (whiteBoxCookie.Value); If (Show Times & lt; 2) {Show Times ++; Var cookie = new HttpCookie (cookieName, Featured Times.Tostring ()) {End = New DateTime (). AddMonths (1), secure = false}; HttpContext.Response.Cookies.Set (cookie); ViewBag.IsWhiteBoxActive = True; } And {ViewBag.IsWhiteBoxActive = false; }} And {var cookie = new HTTP cookie (cookie name, "1") {HTTP = true, domain = request. Url.host, expires = datetime Now. Adams (1), Secure = Foti}; HttpContext.Response.Cookies.Add (cookie); ViewBag.IsWhiteBoxActive = True; } Model. Whitebox = white box; } Return Model; }  

My colleague got the problem. This is about setting up the domain as soon as we have removed this line:

  domain = request. Url.host,  

Cookies have started working and are now being built.

The complete update code of the law:

  Personal ABHomeModel Handle Whitebox (ABHomeModel Model) {var white box = _whiteBoxService.GetActiveWhiteBox (); If (white box! = Null) {const string cookie name = "white box"; Var white box cookie = http constance. request. Cookies (Cookies); If (whiteBoxCookie! = Null) {var Display Times = Convert. ToInt32 (whiteBoxCookie.Value); If (Show Times & lt; 2) {Show Times ++; Var cookie = new HTTP cookie (cookie name, displayed times.ToString ()) {HTTP = true, safe = false}; HttpContext.Response.Cookies.Set (cookie); ViewBag.IsWhiteBoxActive = True; } And {ViewBag.IsWhiteBoxActive = false; }} Other {var cookie = new HTTP cookie (cookie name, "1") {httpP = true, expired = datetime. Now. Adams (1), Secure = Foti}; HttpContext.Response.Cookies.Add (cookie); ViewBag.IsWhiteBoxActive = True; } Model. Whitebox = white box; } Return Model; }  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -