get方法和post方法在ASP.NET中有什么区别

今天就跟大家聊聊有关get方法和post方法在ASP.NET中有什么区别,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

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中有什么区别有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。