Presentation is loading. Please wait.

Presentation is loading. Please wait.

MIS Professor Sandvig MIS 324 Professor Sandvig

Similar presentations


Presentation on theme: "MIS Professor Sandvig MIS 324 Professor Sandvig"— Presentation transcript:

1 MIS 324 -- Professor Sandvig MIS 324 Professor Sandvig
9/20/2018 Forms & Validation MIS 324 Professor Sandvig

2 Overview What is validation Server & client validation
Validation tools in .NET MVC: Model – DataAnnotations View – HTML helpers Controller - model

3 What is Validation Checking user inputs for: Datatype Length Required
Suspicious code: HTML & Javascript

4 Why Validate Accidental user errors: Malicious hacking attempts
Missing fields Invalid values , phone, address, etc. Malicious hacking attempts

5 Accidental user errors
Missing fields Invalid credit card Invalid mail address Invalid dates Invalid

6 Malicious Attacks Web forms expose your site to the world.
Typically writing user inputs to database. Database contains valuable information Customer information Credit card info Etc.

7 Malicious Attacks Hackers try to exploit security vulnerabilities
Sql Injection Enter invalid data to throw exceptions Expose code Expose database info

8 Counter Measures Check format: Stronger measures: Email, phone, zip, …
Send with code Send text message Validate address against database Checksum: Credit cards WWU student Id ISBNs

9 Client and Server validation
Browser HTML5 and JavaScript Advantage: Fast, no trip required to server Disadvantage: Easily circumvented Save form to desktop, remove validation, submit

10 Server Validation Form data submitted to server
Data validated on server Advantage: Secure Disadvantage: Requires roundtrip to server More complicated to implement

11 .NET MVC Validation Provides tools for easy validation: Client:
Javascript & HTML5 Server: rechecks, rejects invalid data

12 .NET MVC Validation DataAnnotations
Decorate model with validation attributes Required Data type length Credit card Etc. Easy to implement both client and server validation

13 .Net MVC Validation Validation Attributes: Required StringLength Range
RegularExpression CreditCard CustomValidation Address FileExtension MaxLength MinLength Phone

14 .NET MVC Validation Model: public class Student {
public int StudentId { get; set; } [Required] public string StudentName { get; set; } [Range(5,50)] public int Age { get; set; } }

15 .NET MVC Validation View: Client-side validation:
Include script libraries

16 .NET MVC Validation Model: Server-side validation:
Example: Calculator/MultiplyCalc

17 Summary Form Validation Important Time consuming
Accidental errors Malicious attacks Time consuming .NET MVC provides convenient tools


Download ppt "MIS Professor Sandvig MIS 324 Professor Sandvig"

Similar presentations


Ads by Google