现在数据库方面已经准备就绪,我们接着来完成编程和配置方面的工作。我们不打算从新创建一个解决方案,而是直接对之前演示的实例进行改造。我们采用自我寄宿的方式,由于Membership隶属于ASP.NET,所以我们需要添加System.Web.dll的引用,如果你采用的是.NET Frameowrk 4.0(本例所示的配置也是基于该版本),你还需额外添加对System.Web.ApplicationServices.dll的引用。接下来,我们需要在服务寄宿方面所做的工作就是将下面一段配置整个拷贝到app.config中。
<? xml version="1.0" ?>
< configuration >
< connectionStrings >
< add name ="AspNetDb" connectionString ="Server=.; Database=AspNetDb; Uid=sa; Pwd=password" />
</ connectionStrings >
< system.web >
< membership defaultProvider ="myProvider" >
< providers >
< add name ="myProvider" type ="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
connectionStringName ="AspNetDb" applicationName ="MembershipAuthenticationDemo" requiresQuestionAndAnswer ="false" />
</ providers >
</ membership >
</ system.web >
< system.serviceModel >
< bindings >
< ws2007HttpBinding >
< binding name ="userNameCredentialBinding" >
< security mode ="Message" >
< message clientCredentialType ="UserName" />
</ security >
</ binding >
</ ws2007HttpBinding >
</ bindings >
< services >
< service name ="Artech.WcfServices.Services.CalculatorService" behaviorConfiguration ="membershipAuthentication" >
< endpoint address ="http://127.0.0.1/calculatorservice" binding ="ws2007HttpBinding" bindingConfiguration ="userNameCredentialBinding" contract ="Artech.WcfServices.Contracts.ICalculator" />
</ service >
</ services >
< behaviors >
< serviceBehaviors >
< behavior name ="membershipAuthentication" >
< serviceCredentials >
< serviceCertificate storeLocation ="LocalMachine" storeName ="My" x509FindType ="FindBySubjectName" findValue ="Jinnan-PC" />
< userNameAuthentication userNamePasswordValidationMode ="MembershipProvider" membershipProviderName ="myProvider" />
</ serviceCredentials >
</ behavior >
</ serviceBehaviors >
</ behaviors >
</ system.serviceModel >
</ configuration >
在asp.net以外程序使用membership的配置
最新推荐文章于 2017-04-16 21:11:13 发布