本文整理汇总了C#中IServiceCollection.AddSmartCookies方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceCollection.AddSmartCookies方法的具体用法?C# IServiceCollection.AddSmartCookies怎么用?C# IServiceCollection.AddSmartCookies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceCollection
的用法示例。
在下文中一共展示了IServiceCollection.AddSmartCookies方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddSmartCookies();
services.AddMvc()
.AddMultiTemplateEngine()
.AddCookieTemplateProvider();
}
示例2: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
#region Adding Entity Framework v7
services.AddEntityFramework()
.AddSqlite()
.AddDbContext<ChinaTowerContext>(x => x.UseSqlite($"Data source={PlatformServices.Default.Application.ApplicationBasePath}/Database/chinatower.db"));
#endregion
#region Adding Identity v3
services.AddIdentity<User, IdentityRole>(x =>
{
x.Password.RequireDigit = false;
x.Password.RequiredLength = 0;
x.Password.RequireLowercase = false;
x.Password.RequireNonLetterOrDigit = false;
x.Password.RequireUppercase = false;
x.User.AllowedUserNameCharacters = null;
})
.AddEntityFrameworkStores<ChinaTowerContext>()
.AddDefaultTokenProviders();
#endregion
#region Adding Others
services.AddConfiguration();
services.AddMvc();
services.AddSmartCookies();
services.AddSmartUser<User, string>();
services.AddAesCrypto();
services.AddSmtpEmailSender("smtp.ym.163.com", 25, "中国铁塔", "[email protected]", "[email protected]", "123456");
services.AddWgsDis();
#endregion
}
示例3: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
IConfiguration Configuration;
services.AddConfiguration(out Configuration);
var appEnv = services.BuildServiceProvider().GetRequiredService<IApplicationEnvironment>();
var connStr = "Data source=" + appEnv.ApplicationBasePath + "/" + Configuration["DBFile"] + ";";
if (connStr.IndexOf('\\') >= 0)
connStr = connStr.Replace("/", "\\");
services.AddSmartCookies();
services.AddJsonLocalization()
.AddCookieCulture();
services.AddEntityFramework()
.AddSqlite()
.AddDbContext<BlogContext>(options =>
options.UseSqlite(connStr));
services.AddCaching();
services.AddSession(x => x.IdleTimeout = TimeSpan.FromMinutes(20));
services.AddMvc()
.AddTemplate()
.AddCookieTemplateProvider();
}
示例4: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
// Add smart cookies
services.AddSmartCookies();
// Add entity framework and in-memory storage
services.AddEntityFramework()
.AddInMemoryDatabase()
.AddDbContext<SampleContext>(x => x.UseInMemoryDatabase());
// Add identity
services.AddIdentity<Models.User, IdentityRole>(x =>
{
x.Password.RequiredLength = 0;
x.Password.RequireDigit = false;
x.Password.RequireLowercase = false;
x.Password.RequireNonLetterOrDigit = false;
x.Password.RequireUppercase = false;
x.User.RequireUniqueEmail = false;
x.User.AllowedUserNameCharacters = null;
})
.AddEntityFrameworkStores<SampleContext>()
.AddDefaultTokenProviders();
// Add mvc with multi template engine and cookie based template provider
services.AddMvc()
.AddTemplate()
.AddCookieTemplateProvider();
services.AddSmartUser<User, string>();
}
示例5: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
var _serv = services.BuildServiceProvider();
var appRoot = _serv.GetRequiredService<IApplicationEnvironment>().ApplicationBasePath;
IConfiguration Configuration;
services.AddConfiguration(out Configuration);
if (Configuration["Data:DefaultConnection:Mode"] == "SQLite")
{
services.AddEntityFramework()
.AddDbContext<vNextChinaContext>(x => x.UseSqlite(Configuration["Data:DefaultConnection:ConnectionString"].Replace("{appRoot}", appRoot)))
.AddSqlite();
}
else if (Configuration["Data:DefaultConnection:Mode"] == "SqlServer")
{
services.AddEntityFramework()
.AddDbContext<vNextChinaContext>(x => x.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]))
.AddSqlServer();
}
else
{
services.AddEntityFramework()
.AddDbContext<vNextChinaContext>(x => x.UseInMemoryDatabase())
.AddInMemoryDatabase();
}
services.AddIdentity<User, IdentityRole<long>>(x =>
{
x.Password.RequireDigit = false;
x.Password.RequiredLength = 0;
x.Password.RequireLowercase = false;
x.Password.RequireNonLetterOrDigit = false;
x.Password.RequireUppercase = false;
x.User.AllowedUserNameCharacters = null;
})
.AddEntityFrameworkStores<vNextChinaContext, long>()
.AddDefaultTokenProviders();
services.AddMvc();
services.AddSmartUser<User, long>();
services.AddSmartCookies();
services.AddAntiXss();
services.AddSmtpEmailSender("smtp.qq.com", 25, "vNext China", "[email protected]", "911574351", "XXX");
services.AddAesCrypto();
services.AddEFNodeProvider<vNextChinaContext>();
services.AddSignalR();
}
示例6: ConfigureServices
public void ConfigureServices(IServiceCollection services)
{
services.AddEntityFramework()
.AddDbContext<MOContext>(x => x.UseSqlite("Data source=mobileoperation.db"))
.AddSqlite();
services.AddIdentity<User, IdentityRole>()
.AddEntityFrameworkStores<MOContext>()
.AddDefaultTokenProviders();
services.AddFileUpload()
.AddEntityFrameworkStorage<MOContext>();
services.AddMvc();
services.AddSmartUser<User, string>();
services.AddSmartCookies();
}