我对以下内容感到紧张:
我想自动登录已添加到数据库的最近创建的用户。 用户数据在创建后会反映在数据库(SQL Server 2008)中。
登录代码如下:
DatingSite.Views.Signup signupPage = e.Content as DatingSite.Views.Signup;
signupPage.SignupComplete += (se, ev) =>
{
WebContext.Current.Authentication.Login(new LoginParameters(ev.NewUser.email_address, ev.NewUser.password),
(LoginCompleteCallback) =>
{
GetUserInformation();
}, null);
};
[EnableClientAccess()]
public class AuthenticationService : AuthenticationBase<User>
{
}
public class User : UserBase
{
// Profile properties that should be exposed as the user object
// User information
public string CurrentTheme { get; set; }
}
尝试执行此登录指令时,我收到此消息底部的错误。
我将以下内容插入到我的网络配置文件中:
身份验证模式=&#34;表单&#34;
System.NullReferenceException:未将对象引用设置为对象的实例。
在System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService。&lt;&gt; c_ DisplayClass1 1.<WrapCompleteAction>b__0(T ao)
at System.ServiceModel.DomainServices.Client.ApplicationServices.LoginOperation.InvokeCompleteAction()
at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object result)
at System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.End(IAsyncResult result)
at System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.<>c__DisplayClass1.<HandleAsyncCompleted>b__0(Object state)
at System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.RunInSynchronizationContext(SendOrPostCallback callback, Object state)
at System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.HandleAsyncCompleted(IAsyncResult asyncResult)
at System.ServiceModel.DomainServices.Client.AsyncResultBase.Complete()
at System.ServiceModel.DomainServices.Client.ApplicationServices.WebAuthenticationService.HandleOperationComplete(OperationBase operation)
at System.ServiceModel.DomainServices.Client.LoadOperation.<>c__DisplayClass4
1.b _0(LoadOperation 1 arg)
at System.ServiceModel.DomainServices.Client.LoadOperation
1.InvokeCompleteAction()
在System.ServiceModel.DomainServices.Client.OperationBase.Complete(对象结果)
在System.ServiceModel.DomainServices.Client.LoadOperation.Complete(DomainClientResult结果)
在System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult)
在System.ServiceModel.DomainServices.Client.DomainContext。&lt;&gt; c_ DisplayClass1b.b _17(Object)}
请帮帮我......
答案 0 :(得分:0)
我假设您已使用FormsAuthentication身份验证属性实例化了一个WebContext对象。如果你没有,那么预期的错误就像NotSupportedException。但为了以防万一,请将以下行添加到App.xaml.cs。
var webContext = new WebContext();
webContext.Authentication = new FormsAuthentication();
ApplicationLifetimeObjects.Add(webContext);