public IActionResult Register(SysUser usr)
{
if (!ModelState.IsValid)
{
ViewData["Message"] = "Invalid Input";
ViewData["MsgType"] = "warning";
return View("UserRegister");
}
else
{
string insert =
@"INSERT INTO SysUser (UserId, UserPw, FullName, Email, CorporateId, UserRole) VALUES
('{0}', HASHBYTES('SHA1', '{1}'), '{2}', '{3}', {4}, 'user')";
if (DBUtl.ExecSQL(insert, usr.UserId, usr.UserPw, usr.FullName, usr.Email) == 1)
{
usr.ActivationToken = Guid.NewGuid().ToString();
if (usr.ActivationToken != null)
{
string inst = @"INSERT INTO SysUser(Active)VALUES('1')";
if (DBUtl.ExecSQL(inst, usr.Active) == 1)
{
string template = @"Hi {0},<br/><br/>
you have successfully created an account at Parkway Pantai Health Screening Portal.
Please click on the link below to verify your email address and complete your registration. Your user id is <b>{1}</b> and password is <b>{2}</b>.
<br/>";
template+= "</br><a href= '" + Request.Url.AbsoluteUri.Replace("CS.aspx", "CS_Activation.aspx?ActivationToken"+ usr.ActivationToken
) + "'>Click here to activate your account.</a>";
string title = "Registration Successul - Welcome";
string message = String.Format(template, usr.FullName, usr.UserId, usr.UserPw);
string result = "";
bool outcome = false;
// TODO: L10 Task 2b - Call EmailUtl.SendEmail to send email
// Uncomment the following line with you are done
outcome = EmailUtl.SendEmail(usr.Email, title, message, out result);
if (outcome)
{
ViewData["Message"] = "User Successfully Registered";
ViewData["MsgType"] = "success";
}
else
{
ViewData["Message"] = result;
ViewData["MsgType"] = "warning";
}
}
else
{
ViewData["Message"] = DBUtl.DB_Message;
ViewData["MsgType"] = "danger";
}
}
}
return View("UserRegister");
}
}
Hi all, I am trying to send a activation link using Guid.NewGuid() and when I want to generate a link using "Request.Url.AbsoluteUri.Replace" it shows a error where it says:
'HttpRequest' does not contain a definition for 'Url' and no accessible extension method 'Url' accepting a first argument of type 'HttpRequest' could be found (are you missing a using directive or an assembly reference?).
Is there any workaround to this? The framework i am using is c# .net framework 3.1. Thanks in advance for the help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…