Each time, like trying to send an email, I will not be sent, but it says:
An unhandled exception occurred while processing the request. ArgumentNullException: Value cannot be null. Parameter name: Templates/NewPassword does not match any available view
This is what it looks like when I refer to the file.
That's how I've tried to look here.Github - Paris Plyzos
Also code here:
var resultMail = await _viewRenderService.RenderToStringAsync("Templates/NewPassword", viewModel); //ERROR HERE!
var client = new SendGridClient(m.azureName());
var from = new EmailAddress(m.mailFrom(), m.nameFrom());
var to = new EmailAddress(mail, UserValue.Navn);
var plainTextContent = Regex.Replace(resultMail, "<[^>]*>", "");
var msg = MailHelper.CreateSingleEmail(from, to, title, plainTextContent: plainTextContent,
htmlContent: null);
var resulta = client.SendEmailAsync(msg);
return RedirectToAction("UserPassword");
RenderToStringAsync code here - I've written an error where the error goes wrong here.
public async Task<string> RenderToStringAsync(string viewName, object model)
{
var httpContext = new DefaultHttpContext { RequestServices = _serviceProvider };
var actionContext = new ActionContext(httpContext, new RouteData(), new ActionDescriptor());
using (var sw = new StringWriter())
{
var viewResult = _razorViewEngine.FindView(actionContext, viewName, false);//ERROR HERE
if (viewResult.View == null)
{
throw new ArgumentNullException($"{viewName} does not match any available view");
}
var viewDictionary = new ViewDataDictionary(new EmptyModelMetadataProvider(), new ModelStateDictionary())
{
Model = model
};
var viewContext = new ViewContext(actionContext, viewResult.View, viewDictionary, new TempDataDictionary(actionContext.HttpContext, _tempDataProvider),
sw,
new HtmlHelperOptions()
);
await viewResult.View.RenderAsync(viewContext);
return sw.ToString();
}
}