asp.net - FormsAuthenticationTicket disappeared after Response.Redirect operation -
i developed website asp.net. make authentification.
authorization made web service. if answer web-service success, create ticket:
var ticket = new formsauthenticationticket(1, param.login, datetime.now, datetime.now.adddays(1), false, string.empty, formsauthentication.formscookiepath); var encticket = formsauthentication.encrypt(ticket); var authcookie = new httpcookie(formsauthentication.formscookiename) { value = encticket, expires = datetime.now.adddays(1) }; response.cookies.set(authcookie);
this code added authentification cookie. if add next string after previous code:
response.redirect("<redirect address>");
cookie disappeared after redirect.
why it's happened?
web.config part of authentification here:
<authentication mode="forms"> <forms name=".aspxformsauth" loginurl="~/login.ashx" /> </authentication>
it may happen cookie data being associated cookie has exceed maximum allowed size in encrypted format. unencrypted, data not large.
large size of cookie may result in dropping of cookie response header. below fixes worth trying:
- reduce amount of data set in cookie
- try cookie once in unencrypted format. way confirmed indeed size of cookie creating problem
this post gives information on cookie size.
Comments
Post a Comment