Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Couple things to consider, first the Membership and Role providers are static and are generally only initialized the first time they are accessed within an application. When setup properly in Web.Config, they will call initialize when they are first accessed. </p> <p>Through some testing with a basic set of Providers and the default ASP.NET MVC 2 application, I found that the RoleProvider is generally initialized immediately upon application startup. One thing to note though, if you want to have the providers reinitialized, you'll have to stop your development web server (or iis express, or clear the app pool). That way the application is restarted. If you don't, and the providers have already been initialized, it will never hit those break points as it's already been run.</p> <p>Also, when obtaining an instance of your membership provider, don't do so through creating a new instance of the class (ie var provider = new MyMembershipProvider()), as this will not call the initialize method. Be sure to obtain your provider via Membership.Provider, which will handle all of the setup for your properly configured web.config provider. </p> <p>A good look at the default MVC 2 application, within the AccountModels file (~line 101) provides a fine example. </p> <pre><code>_provider = provider ?? Membership.Provider; </code></pre> <p>The first time it's accessed, it will instantiate the <strong>default</strong> membership provider and call initialize. After that, it remains static to the application and isn't called again until the application is unloaded from memory. ie. Stop the vs web development server.</p> <p>Also, another similiar method of obtaining a specific membership provider can also be found at: <a href="https://stackoverflow.com/questions/623545/how-do-i-call-initialize-on-a-custom-membershipprovider">How do I call Initialize on a custom MembershipProvider?</a></p> <p>Hope this helps :)</p>
 

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