在控制台应用程序中访问 ASP.Net 成员资格?
我正在编写一个简单的实用程序控制台应用程序来将新用户等添加到 SQL Server 会员存储。
我遇到的问题是我似乎无法添加对 System.Web 的引用,因此我无法访问会员资格内容。如何去做这件事呢?
注意:我在 stackoverflow 上发现了一些看起来相似的问题,但答案都是围绕 MVC 的,在尝试了建议的答案后,问题仍然存在。
编辑: 奥德帮助我找到了答案。默认情况下,它按“客户端配置文件”进行过滤,该配置文件没有可用的 System.Web。我必须重新定位到 .Net 4 而不是 .Net 4 客户端配置文件,如以下 MSDN 文章中所述。
I'm writing a simple utility console app to add new users, etc, to an SQL Server Membership Store.
The issue I'm running into is that I can't seem to add a reference to System.Web, so I can't access the Membership stuff. How does one go about doing this?
NOTE: I've found a few questions on stackoverflow that seem similar, but the answers revolved around MVC, and after attempting the suggested answers, the problem still remains.
Edit:
Oded helped lead me to the answer. By default it was filtering by the "client profile", which doesn't have System.Web available. I had to retarget to .Net 4 instead of .Net 4 client profile as described in the following MSDN article.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保您的目标是项目中的完整框架(右键单击项目节点并选择
Properties
) - 在Application
选项卡中,有一个下拉列表目标框架。
确保这不使用客户配置文件。
Make sure you are targeting the full framework in your project (right click on the project node and select
Properties
) - In theApplication
tab there is a drop down forTarget Framework
.Make sure this does not use a client profile.
究竟是什么阻止您在控制台应用程序中添加对 System.Web 的引用?只需通过 VS 中的引用管理添加适当的引用即可。之后,您应该使用 App.config 配置您的应用程序,并像在 Web 应用程序中一样使用会员服务
What exactly prevents to you to add reference to System.Web in a console application? Just add appropriate reference via references management in VS. After that you should configure your application with App.config and work with Membership services as in web applcation