c# - Cookie null in Form authentication -


hi developing web application using mvc4 , used form authentication. every thing works fine noticed strange behavior quite few days. cookie in global.asax null though authentication done in login page due user not able login. below code.

login page.

 userdata = new javascriptserializer().serialize(userdata);             formsauthenticationticket authticket = new formsauthenticationticket(                        1,                       userdetails.userid,                        datetime.now,                        datetime.now.addminutes(90),                        false,                        userdata);                          string encticket = formsauthentication.encrypt(authticket);             httpcookie facookie = new httpcookie(formsauthentication.formscookiename, encticket);             response.cookies.add(facookie);               

global.asax

protected void application_postauthenticaterequest(object sender, eventargs e)         {             httpcookie authcookie = request.cookies[formsauthentication.formscookiename];             if (authcookie != null)             {                  formsauthenticationticket authticket = formsauthentication.decrypt(authcookie.value);                  var s = new system.web.script.serialization.javascriptserializer();                 userinfoauth obj = s.deserialize<userinfoauth>(authticket.userdata);                  userinformation currentuser = new userinformation(obj.userid);                 currentuser.firstname = obj.firstname;                 currentuser.lastname = obj.lastname;                               currentuser.clientidentity = convert.toint32(obj.clientidentity);                 currentuser.useridentity = convert.toint32(obj.useridentity);                  httpcontext.current.user = currentuser;              } 

after fighting more 2 days. found depend upon user data string in form authentication.

formsauthenticationticket authticket = new formsauthenticationticket( 1, userdetails.userid, datetime.now, datetime.now.addminutes(90), false, userdata);

when had less user info in userdata works fine. when userdata contain large info user auth happening in login in globl.asax cookie becoming null. strange. please guide me.

in both scenario cookie created can see in ie11 browser.

the userdata (less data) contain. 147 charcter - working fine.

the userdata (large data) contain. 1045 character - not working.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -