开发者

How to implement cookies less form authentication when we create our own cookie

I am implementing the forms authentication like (I need to create the ticket based some some conditions not from active directory or from database)

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
        "user开发者_开发技巧Name",
        DateTime.Now,
        DateTime.Now.AddMinutes(30), // value of time out property
        false, // Value of IsPersistent property
        String.Empty,
        FormsAuthentication.FormsCookiePath);

string encryptedTicket = FormsAuthentication.Encrypt(ticket);
HttpCookie authCookie = new HttpCookie(
                            FormsAuthentication.FormsCookieName, 
                            encryptedTicket);

authCookie.Secure = true;
Response.Cookies.Add(authCookie);

 and my web.config 


<system.web>
  <authentication mode="Forms">
    <forms loginUrl="Login.aspx"
           protection="All"
           timeout="30"
           name="test" 
           path="/"
           requireSSL="false"
           slidingExpiration="true"
          cookieless="UseDeviceProfile"
           enableCrossAppRedirects="false" />
  </authentication>
</system.web>

This implementation is working fine if the browser cookies are enabled . while it is not working when cookies are disabled( I tried Cookieless="useuri" but it doesnt help)

Can you please guys tell me how should i implement cookiless forms authentication in this scenario

I want to use uri for auth cookie or any other better solution?.


For cookieless browsers asp.net provides session id to embed in URL;

See the below question :

What will happen to asp.net membership if the client browser is not accepting cookies

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜