1

I've been using jQuery to post data and was wondering how best to perform server-side validation on the data. I check the values client-side but know it's good practice to also check server-side.

I've searched online but can't really find any examples.

3 Answers 3

1

There are many ways of doing validation server side, but to make it easy for you you could use an existing library.

the Microsoft Enterprise Library 5.0 offers a bunch of features that you can use to implement common practices. Validation is one of them. Microsoft Enterprise Library is a collection of application blocks designed to assist developers with common enterprise development challenges.

The Enterprise Library Validation Application Block provides useful features that allow developers to implement structured and easy-to-maintain validation scenarios in their applications.

a great sample is found at Using Validation Block Attributes to Define Validation Rule Sets

more here: http://msdn.microsoft.com/en-us/library/ff664356(v=PandP.50).aspx

Sign up to request clarification or add additional context in comments.

2 Comments

Ok the validation blocks seem like a good neat way of doing it. As im doing the validation clientside and the serverside validation is a double check how would i handle invalid data. Should i just throw an exception, log it and inform the user there has been an error in the error method of the jquery ajax procedure.
Note clientSideValidation is not a strong validation, just a user friendly way of telling how to input data. The real job is done on the server.
0

You can either do it manually (ie, if (model.Value != null)), or via data annotations

1 Comment

yeh i just looked and it seems quite interesting. shame its only for mvc
0

Check out ASP.NET server-side validation.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.