何时在C#中使用Javascript验证 [英] When to use Javascript Validation in C#

查看:64
本文介绍了何时在C#中使用Javascript验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要有关何时使用Javascript验证和服务器端验证的信息。是否有任何规则定义或是否有任何书籍澄清上面。

I need information that when to use Javascript validation and server side validation .Is there any rules defined or is there any books which clarifies above.

推荐答案

有没有规则。这取决于验证的重要性。 JavaScript中的验证可以更快,因为它没有任何严重依赖流量的HTTP请求。对于JavaScript,它没关系。



至于重要性,这是更严重的。 JavaScript可以1)由用户关闭,2)用某些恶意软件窃听或伪造。服务器验证没有这个问题(除非服务器主机被感染,这不太可能:-)):即使HTTP请求可以伪造,它也不会损害服务器上的任何东西,因为服务器端验证可以过滤掉任何恶意活动的迹象,比如说,只是默默地忽略恶意请求。



我亲身经历过一些攻击,非常琐碎但非常有害(很容易变成你的服务器主机)变成一个分发垃圾邮件的僵尸),我非常可靠地被服务器端验证阻止了。这是一个非常重要的案例,每个Web开发人员都应该理解它。请参阅我之前关于该主题的帖子:无法发送邮件,它显示以下代码中的错误。 [ ^ ]。



-SA
There are no rules. It depends on how important the validation is. Validation in JavaScript can be faster, because it comes without any HTTP requests which heavily depend on traffic. For JavaScript, it just does not matter.

As to the importance, this is more serious. JavaScript can be 1) switched off by the user, 2) eavesdropped or forged with some malware. Server validation is free from this problem (unless the server host is infected, which is no so likely :-)): even though the HTTP request can be forged, it cannot harm anything on the server, because server-side validation can filter out any signs of malicious activity, and, say, just silently ignore malicious request.

I personally experienced some attack, very trivial yet very harmful (could easily turn your server host into a zombie distributing spam), which I very reliably blocked by server-side validation. This is such an important case, that every Web developer should understand it. Please see my past post on the topic: unable to send mail , it showing the error in below code .[^].

—SA


当您在网页上进行任何验证时,我们非常感谢Java脚本。由于它在客户端工作,与服务器端验证相比,验证的速度会快得多。但请确保您没有验证javascript中的任何机密数据,我的意思是在客户端。

服务器端适用于数据库和网页中的大量数据填充验证。





请参考链接 [ ^ ]





快乐编码:)
When you have any validations on your web page, Then Java script is highly appreciated. As it is working from client side, the speed of validations will be much faster when comparing to server side validations. But ensure that you are not validating any confidential data's in javascript, I mean in client side.
Server side is good for database and huge data population validations in web page.


Please refer this link[^]


Happy Coding :)


请浏览以下链接,

http://stackoverflow.com/questions/162159/javascript-client-side-vs-server-side-validation [ ^ ]



作为程序员,你必须d o客户端和服务器端的验证。因此,您可以避免一些可能遇到的错误。
Please go through the following link,
http://stackoverflow.com/questions/162159/javascript-client-side-vs-server-side-validation[^]

As a programmer you must do the validation both in client side and server side. In that you can avoid some % of errors you may face.


这篇关于何时在C#中使用Javascript验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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