Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Can we control when the IdentityDbContext is created based on where they are on the site? (Too much SQL traffic)

$
0
0

We have two section to the website. A public and a logged in section. 

We notice that SQL is hit every page request. This request is coming from the IdentityDbContext because CreatePerOwinContext has registered this handler during startup.

//Startup Auth (code snip-it)
app.CreatePerOwinContext(ApplicationDbContext.Create);


// Identity Model
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        public ApplicationDbContext(): base("DBConnectionString")
        {
        }

        public static ApplicationDbContext Create()
        {
            return new ApplicationDbContext();
        }
    }



How can we skip Identity when we are on pages that are non-SSL (http), but if they attempt to log in they will be redirected to the SSL/HTTPS and we can "activate" Identity to do the right thing. 

It would be a nice way to improve performance too. Why hit SQL if we don't care about the identity for public/static pages? 

Thoughts? 

Thank you.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>