Accessing ASP.Net Membership in a Console Application?

无人久伴 提交于 2019-12-11 13:04:20

问题


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.

http://msdn.microsoft.com/en-us/library/bb398202.aspx


回答1:


Make sure you are targeting the full framework in your project (right click on the project node and select Properties) - In the Application tab there is a drop down for Target Framework.

Make sure this does not use a client profile.




回答2:


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



来源:https://stackoverflow.com/questions/9398194/accessing-asp-net-membership-in-a-console-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!