File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
ExampleNet45ASPNetProject/SendGrid.ASPSamples Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ public ActionResult Send()
2323 [ HttpPost ]
2424 public ActionResult Send ( EmailContract emailContract )
2525 {
26+ if ( ! ModelState . IsValid )
27+ {
28+ return View ( model ) ;
29+ }
30+
2631 try
2732 {
2833 var response = _sendGridEmailService . Send ( emailContract ) ;
@@ -37,4 +42,4 @@ public ActionResult Send(EmailContract emailContract)
3742 }
3843
3944 }
40- }
45+ }
Original file line number Diff line number Diff line change @@ -10,22 +10,30 @@ public class EmailContract
1010 {
1111 [ Required ]
1212 [ Display ( Name = "From Email Address" ) ]
13+ [ EmailAddress ]
1314 public string FromEmailAddress { get ; set ; }
1415
1516 public string Alias { get ; set ; }
1617
1718 [ Required ]
1819 [ Display ( Name = "To Email Address" ) ]
20+ [ EmailAddress ]
1921 public string ToEmailAddress { get ; set ; }
22+
2023 [ Display ( Name = "Cc Email Address" ) ]
24+ [ EmailAddress ]
2125 public string CcEmailAddress { get ; set ; }
26+
2227 [ Display ( Name = "Bcc Email Address" ) ]
28+ [ EmailAddress ]
2329 public string BccEmailAddress { get ; set ; }
30+
2431 [ Required ]
2532 [ Display ( Name = "Subject" ) ]
2633 public string Subject { get ; set ; }
34+
2735 [ Required ]
2836 [ Display ( Name = "Body" ) ]
2937 public string Body { get ; set ; }
3038 }
31- }
39+ }
You can’t perform that action at this time.
0 commit comments