我有以下几点精神崩溃:
我想自动登录一个最近创建的用户,该用户已经添加到数据库中。用户数据在创建后反映在数据库中( 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; }
}当试图执行这个登录指令时,我会收到消息底部的一个错误。
我将以下内容插入到我的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 )}
请帮帮我..。
发布于 2011-03-07 00:21:42
我假设您实例化了一个具有WebContext身份验证属性的FormsAuthentication对象。如果没有,那么预期的错误将类似于NotSupportedException。但是,为了以防万一,请将以下行添加到App.xaml.cs中。
var webContext = new WebContext();
webContext.Authentication = new FormsAuthentication();
ApplicationLifetimeObjects.Add(webContext);https://stackoverflow.com/questions/5214111
复制相似问题