-
614 votesanswersviews
ASP.NET MVC - 设置自定义IIdentity或IPrincipal
我需要做一些相当简单的事情:在我的ASP.NET MVC应用程序中,我想设置一个自定义IIdentity / IPrincipal . 哪个更容易/更合适 . 我想扩展默认值,以便我可以调用类似 User.Identity.Id 和 User.Identity.Role 的内容 . 没什么特别的,只是一些额外的属性 . 我让它变得比实际更难 . 我觉得这很容易 . 如果用户登录,我想设置自定义II... -
3 votesanswersviews
MVC2 ::我如何*使用*自定义IIdentity类?
我试图从Web服务存储一整套关于用户的信息 . 由于这是有关当前经过身份验证的用户的信息,我认为将该信息存储在自定义IIdentity实现中是有意义的 . 自定义 MagicMembershipProvider.GetUser(string id, bool userIsOnline) 调用webservice并返回一个 MagicMembershipUser 实例,其中填充了所有字段(部门,电话... -
19 votesanswersviews
在MVC3中使用自定义IPrincipal和IIdentity
我创建了自己的 IPrincipal 和 IIdentity 实现,如下所示: [ComVisible(true)] [Serializable] public sealed class CustomIdentity : IIdentity { private readonly string _name; private readonly string _email; /... -
0 votesanswersviews
ASP .NET中没有表单身份验证的基于角色的安全性
我想利用: Page.User.IsInRole("CustomRole"); Page.User.Identity.IsAuthenticated 在Page方法中工作时,以及web.config中的 authorization 部分: <authorization> <allow roles="Administrator... -
8 votesanswersviews
在ASP.NET中拒绝用户时'CustomIdentity'上的SerializationException
我尝试在现有数据库的基础上实现ASP.NET身份验证和授权 . 我们有一个网站调用webservice来获取其数据 . 要使用Web服务,我需要提供用户名和密码 . 知道这一点,我决定实施IIdentity和IPrincipal来存储加密的密码,并能够在执行webservice调用时提供它 . 在将来,我们可能希望使用更多asp.net的内置安全性,因此我实现了成员资格和角色提供程序并覆盖了我需要... -
19 votesanswersviews
在MVC中实现自定义标识和IPrincipal
我有一个基本的MVC 2 beta应用程序,我正在尝试实现自定义Identity和Principal类 . 我创建了实现IIdentity和IPrincipal接口的类,实例化它们,然后将CustomPrincipal对象分配给Global.asax的Application_AuthenticateRequest中的Context.User . 这一切都成功,对象看起来很好 . 当我开始渲染视图时... -
5 votesanswersviews
使用自定义成员资格和角色提供程序在MVC中实现IPrincipal和IIdentity
我坚持使用自定义iprincpal和iidentity对象的实现 . 我现在花了一天时间来搜索如何实现这些权利并用更多信息扩展它 . 我想用自定义变量(如全名或其他)扩展信息 @Context.User.Identity.Name . EDIT :现在我得到了以下代码但是如果我尝试阅读 @((CustomPrincipal)Context.User.Identity).Nachname 我收到的... -
4 votesanswersviews
RoleProvider不能在服务器上使用自定义IIdentity和IPrincipal
我在我的 ASP.NET MVC 应用程序中通过 EF 4.3 使用自定义 IIdentity 和 IPrincipal 作为expalined here(并按照接受的答案解决方案) . 另外,我有一个自定义 RoleProvider . In local (using IIS Express), it works currectly . 但现在,当我在真实主机上传应用程序时,似乎所有用户... -
39 votesanswersviews
在.NET中IIdentity和IPrincipal背后的想法是什么?
那么, IIdentity 和 IPrincipal 的存在目的是什么,而不是 IIdentityMergedWithPrincipal ?什么时候在同一个类中实现它们是不够的? 另外,为了理解目的,我想知道这个概念来自哪里: 它起源于.Net Identity / Principal的概念是设计模式,在这些接口中实现了 System.Security.Principal 它起源于其他... -
4 votesanswersviews
User类应该实现IPrincipal和IIdentity
我正在为asp.net web api 2构建我自己的基于令牌的身份验证,我对 user 类有疑问 . 目前我的 user 类实现 IPrincipal 和 IIdentity ,但我不知道什么是最佳做法 . 你会分割 IPrincipal 和 IIdentity 并使 IIdentity 实现成为 IPrincipal 的成员吗? 目前我使用以下类声明 class User : IPrincip... -
0 votesanswersviews
购物车在IIdentity IPrincipal
我正在为我的客户设计订单管理系统 . 在这个系统中,我决定使用IPrincipal而不是IIdentity . 我一直在想我应该在哪里存储客户的购物车数据 . 最后我决定存储在Cookie中 . My first question is: Where should I store customer cart data ? In database or In cookie ? 我认为在cookie中...