客户端和服务器端验证的影响 [英] Impact of both client side and server side validations

查看:110
本文介绍了客户端和服务器端验证的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

在这个论坛上提问似乎是一个非常主要的问题,但我无法通过谷歌搜索全天清除我的疑虑。所有文章均声明,即使正确放置了客户端验证,服务器端验证也是必需的。我们不能单独依赖客户端,因为用户可能会在客户端禁用javascript。但是如果我在双方都写相同的验证,那么性能会降低,因为相同的验证首先在客户端执行两次&然后在服务器端。如何解决这个问题。



我尝试过:



谷歌搜索了一整天后,我了解到总是在服务器端编写验证以获得更好的可靠性和安全性。但我担心它会影响应用程序性能。

Hi All,
It seems to be very primary question to ask in this forum but I can't clear my doubts by googling all the day. All articles states that server side validations are mandatory even if client side validations are properly placed. We can not relies on client side alone because user may disable javascript on client side. But if I write same validations on both sides, then performance is degrades as same validations executes twice first on client side & then on server side. How to target this issue.

What I have tried:

After googling for whole day, I learnt that always write validations on server side for better reliability and security. But I afraid that it will impact on application performance.

推荐答案

性能不会下降。无论如何,您都应该进行服务器端验证。客户端验证是一个很好的,必须使其对用户更具响应性。因此,如果您要跳过1,请跳过客户端。



但它不会影响性能。客户端验证在客户端的浏览器中执行,应该非常快。如果全部通过则表单将作为单独的进程提交并在那里进行验证。
The performance does not degrade. You should do server side validations no matter what. Client side validations are a nice to have to make it more responsive to the user. So, if you are going to skip 1, skip client side.

But it does not affect performance. Client side validation executes in the client's browser and should be very fast. If it all passes then the form is submitted as a separate process and validation happens there.


它会在页面请求上添加几毫秒,这样客户端的时间很短甚至不会察觉它,并且考虑到几毫秒人们不介意添加验证的重要性。
It'll add a few milliseconds onto the page request, such a small amount of time that the client won't even perceive it and given the importance of validation that's a few milliseconds people don't mind adding.


这篇关于客户端和服务器端验证的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆