gpt4 book ai didi

iphone - 如何从 iPhone 和 WCF 创建 ASP.Net/Umbraco SQL 成员资格的用户?

转载 作者:行者123 更新时间:2023-12-03 19:59:54 27 4
gpt4 key购买 nike

所以我已经挣扎了好几天了,尝试使用 Umbraco 的成员(member)提供商简单地创建一个具有 WCF 服务的新用户。有人可以告诉我我是否疯了,如果这是不可能做到的,或者如果我忽略了一些我需要添加到我的 WCF 服务中才能使其工作的东西。我的 WCF 脚本使用 .NET Framework 4.0 嵌入到我在 IIS 7.5 上的网站中。

我目前可以从 WCF 返回 JSON 字符串,例如输入验证。我将通过 iPhone 应用程序使用它。

但是一旦一切都验证成功,我就会尝试运行以下几行...

  MembershipCreateStatus status;    
MembershipUser newUser = Membership.CreateUser(email, pw1, email, "n", "n", false, out status);

if (newUser != null)
{
string newUserGuid = System.Guid.NewGuid().ToString("N");
MemberProfile mp = MemberProfile.GetUserProfile(email);
mp.AuthGuid = newUserGuid;
mp.FirstName = fname;
mp.LastName = lname;
mp.Birthday = bDay;
mp.DisplayRealName = intName;
mp.DisplayBirthday = intBirthday;
mp.Save();
Roles.AddUserToRole(email, "Client");
return @"Valid:User Added";
}else
return @"Error:Invalid:Error Occurred";
}

我收到以下错误...

The server encountered an error processing the request. The exception message is 'Object reference not set to an instance of an object.'. See server logs for more details. The exception stack trace is:

at umbraco.cms.businesslogic.member.Member.GetMemberFromLoginName(String loginName) at umbraco.providers.members.UmbracoMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status) at System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, MembershipCreateStatus& status) at MyDll.Web.AUsers.RegisterUser(String email, String pw1, String pw2, String fname, String lname, Int32 intName, String birthdate, Int32 intBirthday) at MyDll.Web.get.Users.Register(String email, String p1, String p2, String fname, String lname, String displayname, String birthdate, String displaybirth) at SyncInvokeRegister(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

我的 Web 配置部分如下所示...

<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="jsonBinding" maxReceivedMessageSize="2147483647">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="MyDll.Users">
<endpoint address="/get/Users.svc" behaviorConfiguration="jsonBehavior"
binding="webHttpBinding" bindingConfiguration="jsonBinding"
name="UsersService" contract="MyDll.Web.get.Users" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="jsonBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment
multipleSiteBindingsEnabled="true" />
</system.serviceModel>

任何帮助将不胜感激。如果我可以给你买一瓶或十瓶啤酒,我会的。谢谢!

最佳答案

在umbraco Member.cs中,有

HttpContext.Current.Trace.Warn("No member with loginname: " + loginName + " Exists");

所以你遇到了这样的错误。

在 web.config 下的 system.serviceModel 添加:

<serviceHostingEnvironment aspNetCompatibilityEnabled=”true”/>

根据您的服务等级

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

欲了解更多信息,请参阅 http://msdn.microsoft.com/en-us/library/aa702682.aspx

http://our.umbraco.org/forum/developers/api-questions/18465-Access-Umbraco-Content-from-WCF-Service

关于iphone - 如何从 iPhone 和 WCF 创建 ASP.Net/Umbraco SQL 成员资格的用户?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5099233/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com