Created
June 12, 2018 07:14
-
-
Save kevinrodriguez-io/c4ed5e41eefb1b5e605d60fc8606fc62 to your computer and use it in GitHub Desktop.
ASP.Net Core Identity UI 2.1 EmailSender parameterized registration on Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... Usings | |
using Microsoft.AspNetCore.Identity.UI.Services; | |
using MailSenderApp.Services; | |
namespace MailSenderApp { | |
public class Startup { | |
// ... Startup initializer and other methods | |
public void ConfigureServices(IServiceCollection services) | |
{ | |
// ... Other services | |
services.AddDefaultIdentity<IdentityUser>().AddEntityFrameworkStores<ApplicationDbContext>(); | |
services.AddTransient<IEmailSender, EmailSender>(i => | |
new EmailSender( | |
Configuration["EmailSender:Host"], | |
Configuration.GetValue<int>("EmailSender:Port"), | |
Configuration.GetValue<bool>("EmailSender:EnableSSL"), | |
Configuration["EmailSender:UserName"], | |
Configuration["EmailSender:Password"] | |
) | |
); | |
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment