我使用填充业务UI并更新数据库的webService。但在更新数据库之前,我需要创建用户。 ......有谁知道为什么
Membership.CreateUser(user.Username,
System.Web.Security.Membership.GeneratePassword(7, Membership.MinRequiredNonAlphanumericCharacters),
user.Email);
或
Membership.CreateUser(user.Username,
System.Web.Security.Membership.GeneratePassword(7, Membership.MinRequiredNonAlphanumericCharacters),
user.Email,
null,
null,
true,
null,
out status);
不工作....错误是
{System.NotSupportedException:不支持指定的方法。
at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.CreateUser(String username,String password,String email,String passwordQuestion, String passwordAnswer,Boolean isApproved,Object providerUserKey, MembershipCreateStatus&安培;状态)
at System.Web.Security.Membership.CreateUser(String username,String password,String email,String passwordQuestion,String passwordAnswer,Boolean isApproved,Object providerUserKey, MembershipCreateStatus&安培;状态)
at System.Web.Security.Membership.CreateUser(String username,String password,String email)
更新 找到附加的app.config
<?xml version="1.0" encoding="utf-8"?>
<membership defaultProvider="AspNetSqlMembershipProvider">
<!--<providers>
<clear />
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="RFS.DotNetNuke.MembershipConnString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
</providers>-->
<providers>
<remove name="AspNetSqlMembershipProvider"/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="RFS.DotNetNuke.MembershipConnString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="AspNet" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>
<!--<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="AspNetConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="AspNet" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/>-->
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="RFS.DotNetNuke.MembershipConnString" applicationName="/" />
</providers>
</profile>
<!--<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="RFS.DotNetNuke.MembershipConnString" applicationName="/" />
</providers>
</roleManager>-->
<roleManager enabled="true" defaultProvider="AspNetSqlRoleProvider" cacheRolesInCookie="true" createPersistentCookie="false" cookieProtection="All">
<providers>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" applicationName="AspNet" connectionStringName="RFS.DotNetNuke.MembershipConnString" />
</providers>
</roleManager>
WEBCONFIG
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!--LIST OF APP SETTINGS-->
</appSettings>
<connectionStrings>
<!-- LIST OF CONNECTION STRINGS -->
</connectionStrings>
<system.web>
<customErrors mode="Off" />
<compilation debug="true" targetFramework="4.0" />
<machineKey validationKey="xxxx" decryptionKey="xxx" decryption="xxx" validation="xxx" />
<httpRuntime maxRequestLength="xxx"/>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="DotNetNuke.MembershipConnString" enablePasswordRetrieval="false" enablePasswordReset="true" passwordFormat="Encrypted" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="DotNetNuke"/>
</providers>
</membership>
<authorization>
<allow users="wildfire\dev_websvc_sapeai" />
</authorization>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
<defaultDocument>
<files>
<clear />
<add value="default.aspx" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
</files>
</defaultDocument>
</system.webServer>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!--<behavior name="Default_Behaviour">-->
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647" />
<!-- BEGIN: Comment out these settings when running in development -->
<!--<sqlWorkflowInstanceStore instanceCompletionAction="DeleteAll" instanceEncodingOption="None" instanceLockedExceptionAction="NoRetry" connectionStringName="ApplicationServerWorkflowInstanceStoreConnectionString" hostLockRenewalPeriod="00:00:30" runnableInstancesDetectionPeriod="00:00:05" />
<workflowInstanceManagement authorizedWindowsGroup="AS_Administrators" />
<workflowUnhandledException action="AbandonAndSuspend" />
<workflowIdle timeToPersist="00:01:00" timeToUnload="00:01:00" />
<serviceThrottling maxConcurrentCalls="1" maxConcurrentSessions="1" maxConcurrentInstances="1" />
<etwTracking profileName="Personnel Data Tracking" />-->
<!-- END: Comment out these settings when running in development -->
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true">
<serviceActivations>
<add relativeAddress="~/SynchronisePersonnelService.xamlx" service="SynchronisePersonnelService.xamlx" factory="WebServices.SapEai.Workflow.HostFactory"/>
<add relativeAddress="~/SynchroniseOrganisationService.xamlx" service="SynchroniseOrganisationService.xamlx" factory="WebServices.SapEai.Workflow.HostFactory"/>
<add relativeAddress="~/SynchroniseAD_DNN.xamlx" service="SynchroniseAD_DNN.xamlx" factory="WebServices.SapEai.Workflow.HostFactory" />
</serviceActivations>
</serviceHostingEnvironment>
<tracking>
<profiles>
<trackingProfile name="Personnel Data Tracking">
<workflow activityDefinitionId="*">
<workflowInstanceQueries>
<workflowInstanceQuery>
<states>
<state name="*" />
</states>
</workflowInstanceQuery>
</workflowInstanceQueries>
<activityStateQueries>
<activityStateQuery activityName="*">
<states>
<state name="*" />
</states>
<variables>
<variable name="_perNo" />
</variables>
</activityStateQuery>
</activityStateQueries>
<faultPropagationQueries>
<faultPropagationQuery faultSourceActivityName="*" faultHandlerActivityName="*" />
</faultPropagationQueries>
<customTrackingQueries>
<customTrackingQuery name="*" activityName="*" />
</customTrackingQueries>
</workflow>
</trackingProfile>
</profiles>
</tracking>
</system.serviceModel>
</configuration>
注意 我也测试了var
user1 = System.Web.Security.Membership.GetUser(user.Username);
并且这也失败并出现相同的错误,因此问题似乎是MEMBERSHIP。它与访问有什么关系吗?我发现。https://social.technet.microsoft.com/wiki/contents/articles/3855.windows-forms-application-how-to-use-a-membership-provider-of-asp-net-in.aspx
..我尝试更改app配置以适应但没有这样的快乐
在网上找到了很多相关的Q,但没有任何帮助 例如
https://stackoverflow.com/questions/12905343/notsupportedexception-when-casting-membership-getallusers-to-generic-list
我在上述链接中测试了答案,假设我使用的是ClientFormsAuthenticationMembershipProvider(SimpleMembership)而不是默认的SqlMembershipProvider ....所以我测试了
Membership.ValidateUser("john", "john");
应该有效...... 但这失败了......
{System.ArgumentException: The serviceUri configuration setting was not found.
at System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.GetServiceUri()
还尝试从https://docs.microsoft.com/en-us/dotnet/framework/common-client-technologies/how-to-configure-client-application-services
另一篇文章告诉我尝试内置的Windows安全性。https://social.msdn.microsoft.com/Forums/vstudio/en-US/7447d184-adab-42d3-843a-02e992baadcc/how-to-use-membership-and-role-provider-in-a-window-app?forum=netfxbcl
所以我尝试了var user1 = System.Web.Security.Membership.GetUser(user.Username);
但是这次因System.NotSupportedException而失败:不支持指定的方法。
在
System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider.GetUser(String
它还在那篇文章中说重用API和接口来创建自己的子系统......任何人都可以给我一个开始吗?我知道我要做的只是需要一只手来实现它谢谢你(请看下面的链接)
这是我应该做的吗?
https://msdn.microsoft.com/en-us/library/aa479046.aspx