验证在ASP.NET [英] Validation in ASP.NET

查看:99
本文介绍了验证在ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是验证控件,客户端JavaScript验证或服务器端验证的最佳方式?

What's the best way to validate controls, client-side JavaScript validation or server-side validation?

推荐答案

在.NET验证工作都客户端和服务器端。

The .NET validators work both client side and server side.

这是最好的做法,只要你想在客户端的响应,但服务器端的安全性(因为你永远不应该信任客户端 - 总是在服务器上进行验证以及)。

This is best practice, as you want the responsiveness of the client side, but the security of the server side (as you should never trust the client - always validate on the server as well).

例如 - 像萤火虫的工具,JavaScript可能是积极的,但该脚本可以很容易地篡改(因此通过验证客户端上,即使它不应该)。你的服务器端code未暴露给客户端,所以你应该总是的服务器端验证。

For example - with tools like firebug, javascript may be active, but the script can be easily tampered with (so it "passes" validation on the client, even if it shouldn't). Your server side code is not exposed to the client, so you should always also validate on the server side.

这篇关于验证在ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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