今天就跟大家聊聊有关get方法和post方法在ASP.NET中有什么区别,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
ASP.NET 是开源,跨平台,高性能,轻量级的 Web 应用构建框架,常用于通过 HTML、CSS、JavaScript 以及服务器脚本来构建网页和网站。
get方法
html页面:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>发送GET请求</title>
</head>
<body>
<center >
发送GET请求
<hr />
<form action=default7.aspx method =get >
输入发送的内容:
<input type =text name="content1" />
<br />
<input type =submit value ="发送" />
</form>
</center>
</body>
</html>
对应的aspx页面:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>接收GET请求</title>
</head>
<body>
<center >
接收GET方法传来的内容:
<hr />
<%
string content = Request.QueryString["content1"];
Response.Write("GET方法发送过来的内容为:"+content);
%>
</center>
</body>
</html>
post方法
html页面:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>发送post请求</title>
</head>
<body>
<center >
发送post请求
<hr />
<form action =default8.aspx method =post >
输入发送的内容:
<input type =text name="content1" />
<br />
<input type =submit value ="发送" />
</form>
</center>
</body>
</html>
对应的aspx页面:
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>接收post请求</title>
</head>
<body>
<center >
接收post方法传来的内容:
<hr />
<%
string content=Request .Form ["content1"];
Response.Write("POST方法发送过来的内容为:"+content);
%>
</center>
</body>
</html>
用get方法,当执行aspx页面时,地址栏的显示有一段字符“?content1=html输入的值”,而用post方法,没显示,相比之下,post方法比较安全适用。
看完上述内容,你们对get方法和post方法在ASP.NET中有什么区别有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。