Accessing ASP.Net Membership in a Console Applicat

2019-08-01 09:02发布

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

2条回答
Evening l夕情丶
2楼-- · 2019-08-01 09:39

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.

查看更多
劳资没心,怎么记你
3楼-- · 2019-08-01 09:44

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

查看更多
登录 后发表回答