POCO的新ASP.NET身份和MVC 5.0 +基于声明的标识 [英] POCO's with the new ASP.NET Identity and MVC 5.0 + claims-based Identity

查看:140
本文介绍了POCO的新ASP.NET身份和MVC 5.0 +基于声明的标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用VS 2013 RTM的新版本和asp.net的MVC 5.0,我决定尝试一些东西......

With the new version of VS 2013 RTM and asp.net mvc 5.0, I’ve decided to try out a few things...

不用说,发生了很多变化。例如,新的 ASP.NET身份是更换旧成员和(不老) SimpleMembership 的API。

Needless to say, a lot has changed. For example, the new ASP.NET Identity is a replacement of the old Membership and (less old) SimpleMembership APIs.

在所有previous应用我建了,我从来没有与会员或SimpleMembership工作的机会。我一直都结束了创建我自己的登录()方法,将提交的视图模型转换为POCO(使用automapper),这反过来会使用某种数据存储到查找的用户名和密码。

In all previous applications I’ve built, I never had the chance to work with Membership or with SimpleMembership. I’ve always ended up creating my own Login() method which would convert a submitted ViewModel to a POCO (using automapper) which in turn, would use some sort of repository to lookup the user and password.

在回报,我会获得用户的POCO,后来(使用automapper)转换为更小的UserSession POCO。较小的UserSession将是会议的地方。

In return, I would obtain a User POCO that would later be converted (using automapper) to a smaller UserSession POCO. The smaller UserSession would be place in Session.

当然,我仍然会使用 FormsAuthentication 来创建一个加密票证,并使用 FormsAuthentication.SignOut()当用户想注销。

Of course, I would still use FormsAuthentication to create an Encrypted Ticket and use FormsAuthentication.SignOut() when the user wanted to logoff.

不过,我从来没有完全利用了什么会员(或SimpleMembership)的必须提供的。

But I never fully took advantage of what Membership (or SimpleMembership) had to offer.

我从来没有我的波苏斯实现某种接口也没有我要补充我的POCO类库里面微软的库的引用。换句话说,我从未有过任何东西强依赖性。

I never had my POCOs implement some sort of Interface nor did I have to add a reference to the Microsoft’s libraries inside my POCO class library. In other words, I never had a strong dependency on anything.

我的问题是:

通过我明白了,我不断看到新的ASP.NET身份创建(通过code第一)一些表和字段的例子。例如, AspNetUsers 表持有编号字段作为字符串。当然,我敢肯定有办法克服这一点,并最终将看到的例子,但为什么会有人不想打造的纯POCO类并有如何创造的东西是什么,总控制?

With the examples I see, I keep seeing that the new ASP.NET Identity creates (via code first) some tables and fields. For example, the AspNetUsers table holds an Id field as a string. Of course, I’m sure there is a way to overcome this and will eventually see examples, but why would anyone NOT want to build pure POCO classes and have total control of what and how things are created?

除非我很困惑(其中有一个高概率),任何人都可以解释为什么我会想使用新的ASP.NET身份API(或更重要的是,使用新的 Microsoft.AspNet.Identity .EntityFramework )创建我的表?

Unless I’m confused (which has a high probability) can anyone explain why I would want to use the new ASP.NET Identity API (or more importantly, use the new Microsoft.AspNet.Identity.EntityFramework) to create my tables?

什么是在想用这个,而不是事物的POCO风格的优点和缺点

也许我应该问这样一个不同的问题,但我也想了解我怎么能同时使用,而不是与ASP.NET识别生成的实体受益波苏斯新的基于声明的身份。

Perhaps I should be asking this in a different question, but I’m also trying to understand how can I benefit the new claims-based Identity while using POCOs instead of Entities generated with ASP.NET Identity.

随意点我在澄清了正确的方向。

Feel free to point me in the right direction for clarifications.

推荐答案

您完全可以创建自己的UserManager,至极我不推荐,除非你有关于works.you如何包装它现有的UserManager做出了强大的知识您的应用程序依赖于一个接口或只是用它directely和微软已经建立了吧。如果你不喜欢你EF可以创建自己的商店使用其他数据库的好处。新的ASP.NET身份是可扩展的不够,我同意,是有点硬,如果你想充分CONTROLE和定制的一切,但我考虑推荐时间来了解它的大部分,所以你可以选择何时使用或not.most的时间就足够使用现有的UserManager。

you can create your own UserManager completely,wich i don't recommand unless you have a strong knowledge about how it works.you can wrap the existing UserManager and make you application rely on an interface or just use it directely and benefit from what microsoft has put in it.if you don't like EF you can create your own Store to use another Database. the new ASP.NET Identity is extensible enough,i agree that is kinda Hard if you want to take full controle and customize everything,but i recommand taking time to understand the most of it so you can choose when to use or not.most of time it's enough to use the existing UserManager.

这篇关于POCO的新ASP.NET身份和MVC 5.0 +基于声明的标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆