因为MembershipProvider基类是在命名空间System.Web.Security下,所以必须要创建file-->New-->ASP.Net Web Application-->Empty新项目,才能在代码中使用MembershipProvider基类。


提示:

《C#高级编程》中第572页中的实例,需要同时运行两个项目,分别是:

1、AppServices项目 用来实现认证的web类库,等待应用程序来认证。

2、再启用AuthenticationServices项目,即需要做认证的客户端程序。


Appservices项目中,web属性页的设置,如图:

【C#】基于webservice的身份验证,如何创建新项目_c#


AuthenticationServices项目中,Services属性页的设置,如图:

【C#】基于webservice的身份验证,如何创建新项目_MembershipProvider_02


说明:

这种认证方式的好处是,可以实现应用程序代码,与认证代码分离。一个认证web类库,可以被多个应用程序共享。


参考链接:

http://aspalliance.com/1595_Client_Application_Services__Part_1.all