本文介绍了如何覆盖Silvelright 4 RIA服务的AuthenticationService User.IsInRole的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始了与Silverlight 4的导航应用程序模板(启用RIA服务)。 (因为我真的不喜欢臃肿的商务应用模板)
我已经添加了一种验证服务,我能够对用户进行认证,
但是想覆盖User.IsInRole方法。

I've started out with the Silverlight 4 Navigation Application template (RIA Services enabled). (As I really don't like the bloated Business Application Template)I've added an Authentication Service and I'm able to authenticate users,but want to override the User.IsInRole method.

WebContext.Current.User.IsInRole("Guest");

但我找不到任何地方重写的行为。

But I cannot find any place to override the behaviour.

推荐答案

你到底想干什么? User.IsInRole是IPrincipal.IsInRole的实现,真的不应该被忽略。

What are you trying to do? User.IsInRole is an implementation of IPrincipal.IsInRole and really shouldn't be overridden.

如果你想设置的用户角色,你可以做到这一点通过overridding的GetAuthenticatedUser或GetAnonymousUser方法在你的AuthenticationService服务器上。

If you want to set the user roles, you can do it on the server in your AuthenticationService by overridding the GetAuthenticatedUser or GetAnonymousUser methods.

如果你想类似于IsInRole方法,你可以在客户端上的部分类扩展的用户类型,并添加任何方法才有意义。

If you want a method similar to IsInRole, you can extend the User type with a partial class on the client and add whatever methods make sense.

这篇关于如何覆盖Silvelright 4 RIA服务的AuthenticationService User.IsInRole的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 21:36