Note that there are some explanatory texts on larger screens.

plurals
  1. POBest option to custom Authentication using ASP .NET MVC (Cache, Cookie...)
    primarykey
    data
    text
    <p>I am a bit lost using Authentication with MVC...</p> <p>I´m looking for the best option to use in a big <strong>E-Commerce</strong> site, where the performance is top priority...</p> <p>The two options I´m looking until now are :</p> <ul> <li>Create a <em>FormsAuthenticationTicket</em> and encrypt it into a <strong>cookie</strong>, like implemented here : <a href="http://ondotnet.com/pub/a/dotnet/2004/02/02/effectiveformsauth.html" rel="noreferrer">Cookie implementation</a></li> <li><p><strong>Cache</strong> the Authentication data, like that :</p> <pre><code>protected void Application_AuthenticateRequest(object sender, EventArgs e) { if (HttpContext.Current.User != null) { if (HttpContext.Current.User.Identity.IsAuthenticated) { if (HttpContext.Current.User.Identity is FormsIdentity) { // Get Forms Identity From Current User FormsIdentity id = FormsIdentity)HttpContext.Current.User.Identity; // Create a custom Principal Instance and assign to Current User (with caching) Customer principal = (Customer)HttpContext.Current.Cache.Get(id.Name); if (principal == null) { // Create and populate your Principal object with the needed data and Roles. principal = MyBusinessLayerSecurityClass.CreatePrincipal(id, id.Name); HttpContext.Current.Cache.Add( id.Name, principal, null, System.Web.Caching.Cache.NoAbsoluteExpiration, new TimeSpan(0, 30, 0), System.Web.Caching.CacheItemPriority.Default, null); } HttpContext.Current.User = principal; } } } } </code></pre></li> </ul> <p><a href="http://blog.codevelop.dk/post/2007/11/24/ASPNET-20-Forms-authentication-Keeping-it-customized-yet-simple.aspx" rel="noreferrer">Caching sample here</a></p> <p>What you guys think? </p> <p>Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload