I have this string to format and the exception is thrown on this part (string body ....)
private Task SendEmailConfirmation(UserModel user)
{
var emailService = new EmailUnsecServiceAgent(null);
string body = string.Format("Dear {0} <BR/>Thank you for your registration, " +
"please click on the below link to complete your" +
" registration: <a href=\"{1}\" title=\"User Email Confirm\">{1}</a>",
user.UserName,
Url.Action("ConfirmEmail",
"Account",
new
{
confirmationToken = user.ConfirmationToken,
email = user.Email
},,
Request.Url.Scheme));
return Task.Run(() => emailService.SendEmail("Confirm your account", body, null, true, null, null, null));
}
confirmationToken
and email
are strings and my ConfirmEmail is
[AllowAnonymous]
public async Task<ActionResult> ConfirmEmail(string confirmationToken, string email)
{
var securityService = new SecurityUnsecServiceAgent(null);
UserModel user = securityService.GetUserByConfirmationToken(confirmationToken);
if (user != null)
{
if (user.Email == email)
{
user.ConfirmedEmail = true;
securityService.UpdateUser(user);
return View("RegisterMessage");
}
return View("ConfirmEmail", user);
}
return RedirectToAction("ConfirmEmail", user);
}
and this is the StackTrace:
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name)
at System.Web.Hosting.IIS7WorkerRequest.GetServerVariable(String name)
at System.Web.WebPages.UrlRewriterHelper.WasThisRequestRewritten(HttpContextBase httpContext)
at System.Web.WebPages.UrlRewriterHelper.WasRequestRewritten(HttpContextBase httpContext)
at System.Web.WebPages.UrlUtil.GenerateClientUrlInternal(HttpContextBase httpContext, String contentPath)
at System.Web.WebPages.UrlUtil.GenerateClientUrl(HttpContextBase httpContext, String contentPath)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues, RouteCollection routeCollection, RequestContext requestContext, Boolean includeImplicitMvcValues)
at System.Web.Mvc.UrlHelper.GenerateUrl(String routeName, String actionName, String controllerName, RouteValueDictionary routeValues)
at System.Web.Mvc.UrlHelper.Action(String actionName, String controllerName, Object routeValues)
at SendEmailConfirmation(UserModel user) in c:\Projects\..\Controllers\AccountController.cs:line 361
at Controllers.AccountController.<>c__DisplayClass21.<Register>b__1d() in c:\Projects\..\Controllers\AccountController.cs:line 318
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()