简体   繁体   中英

Using ASP.NET Membership providers in console application

I am creating a console application that will automatically create users into a database of a web application that is built in mvc and uses the built in membership provider and roles for forms authentication.

How can I use the AccountMembershipService and MembershipCreateStatus classes from that in a console application??? I've added assemblies and refrences to System.Web and System.Web.Mvc and security etc but cannot get it to recognise those classes.

Copy the relevant elements from your web projects web.config into the winforms app.config .

System.Web.Mvc is not required, and you'll also have to change from Net 4 Client Profile to .NET 4 under project settings.

Use this guide from MS. Be sure to place the attribute in section in app.config if you use multiple providers otherwise you may get something else as default provider and strange exceptions for provider assemblies too :).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM