本章将按照自顶向下的开发模式,来解释怎样在登录页面上显示自定义的Cookie对象。
(1) 、修改Controllers.CustomerController类。
0052、IAuthenticationService、CookieAuthenticationService
(2)、CookieAuthenticationService类继承于IauthenticationService接口,该类通过自定义和扩展内置身份认证实例的API方法进行登录/登出操作,并在操作过程中所获取相关数据持久化到相应的Cookie值中。
(3) 、在Nop.Web.Framework.Infrastructure.DependencyRegistrar.Register方法中定义语句:
//通过“Autofac”实例方法对身份认证服务的自定义接口及其实现类进行注入操作。
builder.RegisterType<CookieAuthenticationService>().As<IAuthenticationService>().InstancePerLifetimeScope();
(4) 、按F5执行程序,查看Views/Customer/Index.cshtml视图中的Cookies。
(6) 、通过第19、20章中的所有操作“nopCommerce”程序实现了向浏览器中隐
式添加Cookies的功能。
对以上功能更为具体实现和注释见:21-06-30_Nop4.4(023_身份认证权限服务定义具体实现完成,在浏览器中隐式添加相应Cookie)。