.net - Custom RoleProvider with MVC 2.0 -


I have a custom subscription and role provider that I am installing in an application. ASP I use the same providers in the webforms in the net and when the app is compiled and moved, the web The providers are started due to references given in the config.

When I take it to MVC and apply break points to these "starting" methods for these sections, there are no break hits

An oddity: If I use "[Author (roles =" Maroli "]]" The process within a controller and hit that the action goes to the Roleprovider and automatically calls "GetRolesForUser" But still never hit start. This is an issue because I need some of the varibles set out before calling any type of approach.

I know that I can directly call "Start", but it would have been thought that it is automatically in ASP webforms.

Do I have to start them manually in MVC or am I missing something?

To consider some things, first subscription and role providers are stable and generally only one The first entry is done within the application. When properly set up in Web.Config, they will start calling when they first sign in.

Through a few tests with the original group of the provider and the default ASP.NET MVC 2 application, I learned that the RoleProvider usually starts immediately on application startup. However, if you want to resume providers, you must stop your development web server (or clear the IIS Express or Ape pool). In this way the application is restarted. If you do not do this, and the providers have already been started, those break points will never be affected as it is already running.

In addition, when your subscription provider gets an example, do not do so by creating a new example of class (i.e. var provider = new MyMembershipProvider ()), because it calls the initial method Will not Make sure to get your provider through subscription. Provider, who has your properly configured web The configuration will handle all setup for the provider.

A good look at the default MVC 2 application, provides a great example within the AccountModels file (~ line 101).

  _provider = provider ?? Membership.Provider;  

The first time it is accessed, it will instantify the default subscription provider and initially call. After this, it remains stable for the application and unless the application is removed from memory it is not called again. To wit. Versus the web development server.

In addition, another method of obtaining a specific membership provider can also be found:

Hope it helps :)


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -