ASP.NET 中的 Provider 是什么意思?
我很困惑。我们经常听说 ASP.NET 中的 Provider。成员资格提供程序、角色提供程序、XmlDataProvider、自定义提供程序、...
这些是什么以及为什么我们在 ASP.NET 中需要它们?
I've got confused . We hear a lot about Provider in ASP.NET . Membership-Provider , Role Provider , XmlDataProvider ,CustomProvider, ....
What are those and why we need them in ASP.NET ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Provider 是“供应商”的同义词,意思是:
就像在现实生活中一样,提供商是帮助您解决与特定服务的通信或帮助您解决问题的人/事物。
例如,.NET 中的会员资格提供程序用于处理会员资格,例如身份验证、注册新用户以及随之而来的更多选项。
角色提供程序与上述内容密切相关,因为它可以帮助您处理附加到您所拥有的用户的角色(他们有成员资格!)。
您可能想阅读以下内容:来自 MSDN 的 Microsoft ASP.NET 2.0 提供程序简介
Provider is a synonyme with "Supplier" which means:
Just as in real life, a provider is someone / something that helps you solve communicaiton with a certain service or help you solve a problem.
For instance, the Membership Provider in .NET is used to handle Membership such as Authentication, Registering new Users and many more options comes with this.
The Role Provider goes hand in hand with the above, because it helps you handle Roles attached to users that you have in ( They have Memberships! ).
You might want to read this: Microsoft ASP.NET 2.0 Provider Introduction from MSDN
使用 Provider 模型意味着,如果您不喜欢 ASP.NET 中某些内容的工作方式或者您想要/需要扩展它,您可以编写自己的模型。只要它支持 ASP.NET 作为平台的一部分工作所需的核心功能,即继承自 MemrbershipProvider/RoleProvider/WhateverProvider,您就可以在内部做您想做的事情。
然后,您可以换出默认的提供程序并在其位置使用您的提供程序,例如,假设您不使用 SQL Server,您使用 CouchDB 来存储所有数据。您不能使用
SqlMembershipProvider
,但可以编写CouchDBMembershipProvider
* - 只要您继承自MembershipProvider
并重写其方法即可与 CouchDB 一起工作,你就可以开始了。* 我并不是说你应该这样做,我只是说你可以:-)
Using the Provider model means that if you don't like the way something in ASP.NET works or you want/need to extend it, you can write your own. As long as it supports the core functionality that ASP.NET needs to work as part of the platform i.e. it inherits from MemrbershipProvider/RoleProvider/WhateverProvider, you can do what you want in the internals.
You can then swap out the default Provider and use yours in it's place e.g. say you don't use SQL Server, you use CouchDB for all your data storage. You can't use the
SqlMembershipProvider
, but you can write aCouchDBMembershipProvider
* - as long as you inherit fromMembershipProvider
and override its' methods to work with CouchDB you're good to go.* I'm not saying you should do this, I'm just saying you can :-)