protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            // Use LocalDB for Entity Framework by default
            Database.DefaultConnectionFactory =
                new SqlConnectionFactory(
                    "Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            // TODO: Notice how we monitor registrations with durable timers
            RegistrationVerification <AccountRegistration> .MonitorRegistrations();

            BundleTable.Bundles.RegisterTemplateBundles();
        }
Пример #2
0
        private void VerifyRegistration(RegisterModel model)
        {
            // Create a verification workflow using the helper
            var workflow = new RegistrationVerification <AccountRegistration>();

            Debug.Assert(this.Request.Url != null, "Request.Url != null");

            // TODO: Notice how we setup the registration system with sever email templates
            workflow.VerifyRegistration(
                new RegistrationData
            {
                // HTML files created by Visual Studio are UTF8 encoded
                BodyEncoding = Encoding.UTF8,
                // These arguments can be used to insert data into the HTML mail template
                BodyArguments = new[] { model.UserName },
                // These templates will be used in-order to provide email reminders.  After the
                // last email, the verification process will give up and delete the account
                EmailTemplates =
                    new[]
                {
                    this.Server.MapPath("~/Content/RegistrationVerificationEmail.html"),
                    this.Server.MapPath("~/Content/Reminder1Email.html"),
                    this.Server.MapPath("~/Content/FinalReminderEmail.html")
                },
                IsBodyHtml = true,
                // TODO: Modify email properties as required
                From    = "*****@*****.**",
                Sender  = "*****@*****.**",
                Subject = "Registration almost complete",
                To      = new[] { model.Email },
                // Created extension methods to provide fully qualified URLs for email
                VerificationUrl = this.Url.FullyQualifiedAction("Verification"),
                CancelUrl       = this.Url.FullyQualifiedAction("Cancel"),
                StylesUrl       = this.Url.FullyQualifiedContent("~/Content/Site.css"),
                UserName        = model.UserName,
                UserEmail       = model.Email,
            });
        }