wcf ria forms验证的处理方式
来源:互联网 发布:vm桥接模式 无网络 编辑:程序博客网 时间:2024/05/06 22:55
[EnableClientAccess]
public class AuthenticationDomainService : AuthenticationBase<User>
{
}
在客户端app.cs里加上
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
var webContext = new WebContext();
var fa = new FormsAuthentication();
webContext.Authentication = fa;
this.ApplicationLifetimeObjects.Add(webContext);
}
2.自定义一个验证类,添加一个CS文件
[EnableClientAccess]
public class AuthenticationDomainService1 : DomainService, IAuthentication<AuthUser>
{
public AuthUser GetUser()
{
throw new NotImplementedException();
}
public AuthUser Login(string userName, string password, bool isPersistent, string customData)
{
throw new NotImplementedException();
}
public AuthUser Logout()
{
throw new NotImplementedException();
}
public void UpdateUser(AuthUser user)
{
throw new NotImplementedException();
}
}
这里有个问题就是 自定义的User类不能在二个domainservice里使用,如上面<authuser>改成user后,在客户端会生成二个相同的属性,就会出错。因此,自己又加了一个继承userbase的类
在app.cs里要指定,用哪个类来处理验证
public App()
{
this.Startup += this.Application_Startup;
this.Exit += this.Application_Exit;
this.UnhandledException += this.Application_UnhandledException;
InitializeComponent();
var webContext = new WebContext();
var fa = new FormsAuthentication();
webContext.Authentication = fa;
fa.DomainContext = new AuthenticationDomainService1(); //指定验证类
this.ApplicationLifetimeObjects.Add(webContext);
}
通过以上二种方式来实现验证。但有一个问题,如自定义验证,那客户端获取当前用户的代码在形式上与默认方式上有些不同
WebContext.Current.User;
WebContext.Current.Authentication.User;
代码上有时还有点兼容性问题,不得不去改一下。这一点感觉不是很好。(应该是服务器有二个实现IAuthentication接口的domainservice时引起的。只有一个的时候,可以看到webcontext.current.user,如有二个时,则看不到。
怎么感觉上去,很不稳定似的。
- wcf ria forms验证的处理方式
- 一个基于wcf ria的简单登录方式
- forms验证的方式和使用
- 处理WCF异常的方式
- Silverlight中服务通信方式的选择(WCF、Data Service、Ria Service)
- Silverlight中对WCF RIA 的异步调用的同步处理解决办法
- Forms验证的过程
- Forms验证的知识
- Forms验证的过程
- JavaScript的Forms验证
- 更强悍的Silverlight: WCF RIA Services
- WCF RIA方法无效的一种解决方法
- WCF Data Services 与 WCF RIA Services 的比较
- WCF Data Services 与 WCF RIA Services 的比较
- web.config 配置验证方式 Forms
- Forms的角色验证授权
- FormsAuthenticationTicket基于forms的验证
- FormsAuthenticationTicket基于forms的验证
- netty源代码解读-架构流程
- struts.properties
- android timer使用
- C语言的那些小秘密之const修饰符
- 在Centos5.5下配置rsync服务器
- wcf ria forms验证的处理方式
- c++ operator[]的例子
- 转一篇微软官方技术分享 - 管理员如何替用户设置自动答复?
- php5.3.8 配置,测试及案例
- javascript克隆节点
- SS之发展史和Technical Overview
- NSString字符串比较
- 产生随机验证码(控制台)
- 致国内移动广告平台、广告聚合平台及统计平台的一封信