[英]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. 我正在创建一个控制台应用程序,该应用程序将自动将用户创建到以mvc构建的Web应用程序的数据库中,并使用内置的成员资格提供程序和角色进行表单身份验证。
How can I use the AccountMembershipService
and MembershipCreateStatus
classes from that in a console application??? 如何在控制台应用程序中使用
AccountMembershipService
和MembershipCreateStatus
类? I've added assemblies and refrences to System.Web
and System.Web.Mvc
and security etc but cannot get it to recognise those classes. 我已经为
System.Web
和System.Web.Mvc
以及安全性等添加了程序集和引用,但无法识别这些类。
Copy the relevant elements from your web projects web.config
into the winforms app.config
. 将Web项目
web.config
的相关元素复制到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. System.Web.Mvc
不是必需的,您还必须在项目设置下从Net 4 Client Profile
更改为.NET 4
。
Use this guide from MS. 使用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 :).
如果您使用多个提供程序,请务必将该属性放在app.config中的部分中,否则您可能会获得其他内容作为默认提供程序以及提供程序程序集的奇怪异常:)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.