Skip to content

Instantly share code, notes, and snippets.

@kevinrodriguez-io
Created June 12, 2018 07:14
Show Gist options
  • Save kevinrodriguez-io/c4ed5e41eefb1b5e605d60fc8606fc62 to your computer and use it in GitHub Desktop.
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
// ... 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