首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Authentication.Login: AuthenticationService设置为null

Authentication.Login: AuthenticationService设置为null
EN

Stack Overflow用户
提问于 2011-03-06 23:02:34
回答 1查看 658关注 0票数 0

我有以下几点精神崩溃:

我想自动登录一个最近创建的用户,该用户已经添加到数据库中。用户数据在创建后反映在数据库中( Server 2008)。

登录代码如下:

代码语言:javascript
复制
            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);
            };

代码语言:javascript
复制
[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; }
}

当试图执行这个登录指令时,我会收到消息底部的一个错误。

我将以下内容插入到我的web配置文件中:

身份验证mode=“表单”

System.NullReferenceException:对象引用没有设置为对象的实例。在System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationService.<>c_DisplayClass1`1.b0(T ao)在System.ServiceModel.DomainServices.Client.ApplicationServices.LoginOperation.InvokeCompleteAction() at System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object result(在System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.End(IAsyncResult result)在System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.<>cDisplayClass1.b0(Object state)在System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.RunInSynchronizationContext(SendOrPostCallback回调时,(对象状态)(在System.ServiceModel.DomainServices.Client.ApplicationServices.AuthenticationOperation.HandleAsyncCompleted(IAsyncResult asyncResult)在System.ServiceModel.DomainServices.Client.AsyncResultBase.Complete() (在System.ServiceModel.DomainServices.Client.ApplicationServices.WebAuthenticationService.HandleOperationComplete(OperationBase操作)在System.ServiceModel.DomainServices.Client.LoadOperation.<>cDisplayClass4`1.b_0(LoadOperation1 arg) at System.ServiceModel.DomainServices.Client.LoadOperation1.InvokeCompleteAction() (在System.ServiceModel.DomainServices.Client.OperationBase.Complete(Object结果)(在System.ServiceModel.DomainServices.Client.LoadOperation. )在System.ServiceModel.DomainServices.Client.DomainContext.CompleteLoad(IAsyncResult asyncResult完成(DomainClientResult结果)在System.ServiceModel.DomainServices.Client.DomainContext.<>c_DisplayClass1b.b_17(Object )}

请帮帮我..。

EN

回答 1

Stack Overflow用户

发布于 2011-03-07 00:21:42

我假设您实例化了一个具有WebContext身份验证属性的FormsAuthentication对象。如果没有,那么预期的错误将类似于NotSupportedException。但是,为了以防万一,请将以下行添加到App.xaml.cs中。

代码语言:javascript
复制
        var webContext = new WebContext();
        webContext.Authentication = new FormsAuthentication();
        ApplicationLifetimeObjects.Add(webContext);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5214111

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档