asp.net基础学习(2)

form 中 method ="post"与 method ="get"的区别在于。

(1)get:通过URL传值,在URL可以看得到。 post:提交的表单是隐藏在HTTP报文里面的,在URL可以看不得到.

例子:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>
</head>
<body>
<form action ="Handler.ashx" method ="post">
    <input type ="hidden" value ="ture" name="ispostback" />
    <input type ="text" name="number" value ="@value" />
    <input type ="submit" value="自增" />
    @msg;
</form>
</body>
</html>

get:    http://localhost:1954/ashx/Handler.ashx?ispostback=ture&number=0

post:  http://localhost:1954/ashx/Handler.ashx

(2)get传递的数据量是有限的。如果要上传大数据,用post.

(3)get刷新里面的时候不会提示用户。post刷新的时候,因为数据是后台“偷偷”传的数据,浏览器会让用户确认是否重新提交。

posted @ 2011-04-12 17:26  Bruce.陈  阅读(178)  评论(0)    收藏  举报