With regard to efficiency (speed) and security, which is better for saving data to db 1) using the regular way in codebehind (postback) or 2) jquery with webservice method ?
Thank you
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Apparent speed – AJAX, but this will probably not be any quicker than a post-back, and may be slower depending on your method and process. But the speed to return process to the user AJAX is much better, and so it appears much faster. Of course, if you don’t want user progressing and doing more work while the data is saving, this is a bad idea.
If you have a lot of inputs on your page and you only want to send a few of them for saving, then your transfer time will be less with an ajax call, just sending the relevant data. However, if you are sending most or all of the page data, then a postback will be very similar.
The real time consumer is the time to write data to the database ( as @Anthony Scott points out ), and if you do a postback, there is the data transfer time, the data write time and the redisplay page time before the page returns to usability. This can be significant.
As for security, there is no real difference, as they will both pass the same sort of data across the wire. If you are especially concerned about security, then you need to encrypt the data, whichever method you use.