Open JuergenGutsch opened 5 years ago
Comment written by Nick G. on 18.10.2017 18:40:26
Very interesting stuff the Razor pages. I personally prefer the MVC three separate folders but I can see how it can help with small projects.
Thanks for the article!
Comment written by Jürgen Gutsch on 19.10.2017 16:48:17
Thanks for reading :)
Comment written by tha on 23.10.2017 17:11:30
can you post how the full end code look like?
Comment written by Rob on 23.12.2017 21:48:16
Novice Question: Where do the last two code blocks go. Thanks for the Article
Comment written by Jürgen Gutsch on 16.01.2018 17:09:40
Glad you like it :-)
Depends where you wanna place the code to send the mails. Could be a separate email service class or directly in the OnPostAsync method where I put the comment ("// create and send the mail here") in
Comment written by Jürgen Gutsch on 16.01.2018 17:10:19
Please see Robs comment
Comment written by VerdenDev on 26.01.2018 14:11:19
Hi Jürgen,
First time using this site, great article! Coincidentally I think I've also seen some of your answers on StackOverflow before.
Thank you for a great article!
Comment written by viven on 24.02.2018 15:16:57
What about Robs comments?
Comment written by Jürgen Gutsch on 26.02.2018 08:14:53
:-D I mean my reply on robs comment on this post
Comment written by Craig Nicholas on 07.03.2018 10:32:43
Hi Jürgen,
Where is ContactModel defined?
Comment written by Jürgen Gutsch on 07.03.2018 16:07:35
Hi Craig,
Many thanks for the comment.
The ContactModel ist the "code behind" class of the contact cshtml Razor page. Every Razor page has a model class in behind that has the same name as the page and the prefix "Model".
Sorry for the confusion. I expected it to be clear, because this is how Razor pages work.
Comment written by Craig Nicholas on 07.03.2018 16:25:51
Thank you. I don't normally use code-behind so was not sure. Based on your example I have a working test project.
Does it work for gmail, yahoo too? Can someone send message to my gmail account if I use this method?
Hi @FaridGN
Yes, just configure the line with:
message.To.Add(new MailAddress("me@mydomain.com"));
Add your email address here.
If you want to use Gmail, Yahoo, etc. as SMTP, you should configure the SmtpClient:
var smtpClient = new SmtpClient("mail.mydomain.com")
Written on 26.07.2017 07:55:13
URL: http://asp.net-hacker.rocks/2017/07/26/razor-pages-email-form.html