Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Will not grab my Newpassword - does not match any available view

$
0
0

That's when, for example, I'm getting a user on the page. and sends a kind of welcome email to person. then it tells me:

ArgumentNullException: Value cannot be null. Parameter name: Email/NewPassword does not match any available view

It is the case that my registered user is in Account and when I send mail, it is in a folder at Views/Email/NewPassword.

I have used the information contained here.

Email in Views

When I try to "call" the area that I would like to get hold of, I'll do it here. And This piece of code I use in my account controller.

var resultMail = await _viewRenderService.RenderToStringAsync("Email/NewPassword", viewModel);var client =newSendGridClient(m.AzureName());varfrom=newEmailAddress(m.MailFrom(), m.NameFromUsername());var to =newEmailAddress(mail,UserValue.Navn);var plainTextContent =Regex.Replace(resultMail,"<[^>]*>","");var msg =MailHelper.CreateSingleEmail(from, to, title, plainTextContent: plainTextContent,var resulta = client.SendEmailAsync(msg);

In with - RenderToStringAsync

Where errors like happens there is where I have written "the error is here".

public async Task<string>RenderToStringAsync(string viewName,object model){var httpContext =newDefaultHttpContext{RequestServices= _serviceProvider };var actionContext =newActionContext(httpContext,newRouteData(),newActionDescriptor());

        using (var sw =newStringWriter()){var viewResult = _razorViewEngine.FindView(actionContext, viewName,false);//the error is hereif(viewResult.View==null){thrownewArgumentNullException($"{viewName} does not match any available view");}var viewDictionary =newViewDataDictionary(newEmptyModelMetadataProvider(),newModelStateDictionary()){Model= model};var viewContext =newViewContext(actionContext, viewResult.View, viewDictionary,newTempDataDictionary(actionContext.HttpContext, _tempDataProvider),
                sw,newHtmlHelperOptions());

            await viewResult.View.RenderAsync(viewContext);return sw.ToString();}}

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>