Calling angular 4 router with Multiple parameters from C#
Calling angular 4 router with Multiple parameters from C#
I want to call router with multiple parameters using C#.Here is i am making url
var _email = UtilityConverter.Encrypt(Email);
var _userId = UtilityConverter.Encrypt(Convert.ToString(UserId));
// this.router.navigate(['search', { term: term}]);
var _subject = "Email Verification";
StringBuilder sb = new StringBuilder();
sb.Append("<html>");
sb.Append("<body>");
sb.Append("<p>Dear ,</p>");
sb.Append("<p>Please click the below link to verify your email.</p><br>");
sb.Append("<a href='http://localhost:4200/Emailverification/" + _email + "/" + _userId + "'>click here</a>");
sb.Append("<p>Sincerely,<br>-Offey</br></p>");
sb.Append("</body>");
sb.Append("</html>");
return MailUtilityHelper.SendMail(Email, _subject, sb.ToString());
My Email and userid is encrypted which cause the issue.
here is my router with multiple parameter
{path:'Emailverification/:email/:userid', component:EmailVerficationComponent,canActivate : [AuthguardComponent]},
any help will be highly appreciated. gives me following error in console.
1 Answer
1
You are passing only one parameter to you'r router which is Emailverification/something
in you'r case you have to fill both the parameters to the url.
If you want to make route parameters nullable you should declare another route with one parameter and another one with no parameter which should be
{path:'Emailverification', component:EmailVerficationComponent,canActivate : [AuthguardComponent]},
{path:'Emailverification/:userid', component:EmailVerficationComponent,canActivate : [AuthguardComponent]},
{path:'Emailverification/:email', component:EmailVerficationComponent,canActivate : [AuthguardComponent]},
or you can catch error in you'r component:EmailVerficationComponent component.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
localhost:4200/Emailverification/… this is my url which gives me following error
– Shamshad Jamal
1 min ago