Validating forms in asp Jasmin sex cam clip
As several people have said, since you're using data annotation (the [Required] tag in your viewmodel), the good news is that you don't have to add too much to fix your problem.
To prevent it from sending blank emails, add the following to your controller: The Model State will be valid only if the incoming data is not null, which will prevent the rest of the code from being reached (and sending the email).
You would add the validation check/message directly to your view, in the form group for the user input: The html helper Validation Message For will look at your model and grab the message you've listed as being for validation and will display it when the user attempts to post the page.
Along with the other data annotation on your model variables and a Model State check, it will prevent the user from going forward until the fields have content that meets your checks and prevent the rest of the controller method from executing in the event that something null gets past your checks.
The validation control classes are inherited from the Base Validator class hence they inherit its properties and methods.
I hope you will enjoy the tips while programming with MVC Razor.Make sure you have the relevant code for showing the vlaidation messages in your view.