Monday, April 10, 2006

I am probably late to this party, but somehow I recently discover this info so I thought I’d share it anyway. It is possible to use the ASP.NET providers in WinForms. Yes, you may need to read the previous statement again.. go ahead!

 

Ok, so what do you need to do to get the Membership, Roles, Profile, etc, providers to work? Well nothing really… ok just the same things that you would do in ASP.NET. Since the Winforms project templates do not automatically reference “System.Web”, then you will need to add that reference. This of course is achieved using the standard Add Reference window in Visual Studio.

 

 

 

Then, again just like you would in ASP.NET, add the required elements to the “app.Config”.

 

As a refresher this a boiler plate implementation of the standard configuration for memebership …

 

<system.web>

   <membership defaultProvider="SqlProvider"

      <providers>

         <clear />

         <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="MySqlConnection"

            applicationName="MyApplication"

            enablePasswordRetrieval="false"

            enablePasswordReset="true"

            requiresQuestionAndAnswer="true"

            requiresUniqueEmail="true"

            passwordFormat="Hashed" />

      </providers>

   </membership>

</system.web>

 

Lastly, in you project you can use the object model just the same as you would in ASP.NET since the declarative model isn’t exactly available. Hope this was helpful for someone.

4/10/2006 9:57:59 AM (Eastern Standard Time, UTC-05:00)  #    Comments [20]  | 

Theme design by Jelle Druyts