asp.net mvc - authentication cookie -
Using asp.Net MVC 1, I have "Logon" control / page ... I remember " Keep the checkboxes and hits in my controller. I:
FormsAuth.SignIn (username, password, remember)
This method creates a permanent cookie .ASPXAUTH and everything is good at this point .. I have a breakpoint in the other controller, and I saw that once I am logging in to the website..the next "postback" or For the Refresh ... Cookie .XXXA Youth has gone from the collection of cookies ... So ... when I came back to the site, even when I had chosen the "Remember me" option. Then again my credentials ask ...
Why is any idea why?
Renewed:
I think this is not a problem with MVC. I have created a new application with the webform, the page has 1 text box , 1 button to cookie ... and other buttons to write a cookie in a label.
This is my code:
Protected Zero Button 1_Click (Object) Sender, EventAgages E) {HTTP cookie cookie = new HTTP cookie ("Test"); Cookie.value = textbox1.Text; Cookie.Expires = DateTime.Now.AddMinutes (1); Response.Cookies.Add (cookie); } // Here with a breakpoint, I look at the response. Cookie store and I can see my "Test" items there. Protected Zero Button2_Click (Object Sender, EventArgs E) {// Here with a Breakpoint Response. The cookies collection is empty. Label1.Text = Response.Cookies ["test"]. Values ?? "Zero"; }
I have only one result. The cookie has been properly linked to the response. Cookie archive, but the collection in the second postback is again empty ..
The result .. The value of the label gets "zero".
Maybe some configuration? I have never worked before cookies.
As I said earlier that I work with cookies for the first time ...
The problem was that ... I have to use the collection request to get the value back again. Cookies rather than Response.Kooks ... It sounds reasonable because the request is sent from the browser .. (My mistake xP)
So, in short ...
- Responses. Cookies for creating cookies
- Cookie is stored in the browser
- Request. To retrieve the value of the cookie
Thanks everyone!
Comments
Post a Comment