澳门新葡亰平台游戏网站如何向前端推送用户请求的信息?

htmlheadtitle撼雪喷云之答复用户信息/title/headbodyform
action=”getdada.asp” method=”get”p姓名:input name=”name”
size=”20″br电子邮件:input name=”e_mail” size=”40″/p/formhrpinput
type=”submit” value=”发送” input type=”reset” value=”重写”/p/body/html

postinfo.htmheadtitle星河影动之回应用户请求信息/title/headbodyform
action=”postdata.asp” method=”post”

GET: 
1) Data is appended to the URL(QueryString)
2) Data is not secret.(Can be seen by anyone) 
3) It is a single call system 
4) Maximum data that can be sent is 256. 
5) Data transmission is faster 
6) This is the default method for many browsers 

POST: 
1) Data is not appended to the URL but sent as part of Http Body.
2) Data is Secret 
3) It is a two call system. 
4) There is no Limit on the amount of data.That is characters any amount
of data can be sent. 
5) Data transmission is comparatively slow. 
6) No default and should be Explicitly specified.

 

getdata.asp file% =Request.QueryString(“name”) %你好!br您的电子邮件是:%
=Request.QueryString(“e_mail”) %

‘ 使用Post方法 p请输入您的姓名:input name=”name”
size=”20″br电子信箱:input name=”e_mail” size=”40″/p hr pinput
type=”submit” value=”确定” input type=”reset”
value=”重写”/p/form/body/htmlpostdata.asph2% =Request.Form(“name”)
%您好!br您的电子信箱是:% =Request.Form(“e_mail”) %/h2

I  will start the article from with detailed information.

Actually form has two types of in asp.net2.0.
1) Get
2) Post

When working with Get method:

  • We can access all form input variables in the next page which we
    mentioned in the action attribute.
  • All the submitted information is displayed in the address bar as
    part of the URL.
  •  Url Which is not secured because values will be shown in address
    bar

When working with Post method:

  • we can access the variables in the page which we mentioned in the
    action attribute.
  • we can access those variable as shown below
  • which is more secured, variable not accessible

 

Now we will have small application with 2 web pages

1)       default.aspx

2)       Webform.aspx

GET:

  • I have given the value for action attribute is webform1.aspx in the
    default.aspx page with method type

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”Default.aspx.cs”
Inherits=”WebApplication1._Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”” >

<head runat=”server”>

    <title>Untitled Page</title>

</head>

<body>

   <form action=”webform1.aspx”
method=”get” >

   First name: <input type=”text” name=”fname” /><br />

   Last name: <input type=”text” name=”lname” /><br />

   Age: <input type=”text” name=”age” /><br />

   <input type=”submit” value=”Submit” />

 </form>

</body>

</html>

  • Variables will be available in the address bar like below .

http://localhost:50920/webform1.aspx?fname=jhon&lname=smith&age=30
澳门新葡亰平台游戏网站 1

 

  • We can access the variables from the
    Address to Form using Request.QueryString[] like below.

  protected void Page_Load(object sender, EventArgs e)

        {

            if (Request.QueryString[“fname”] != null)

            {

                Response.Write(“fname : ” +
Request.QueryString[“fname”] + n”);

            }

            if (Request.QueryString[“lname”] != null)

            {

                Response.Write(“lname : ” +
Request.QueryString[“lname”] + “”);

            }

       }

POST:

  • Variables will be post to the next page  using Post method type

<%@ Page Language=”C#” AutoEventWireup=”true”
CodeBehind=”Default.aspx.cs” Inherits=”WebApplication1._Default” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“;

<html xmlns=”” >

<head runat=”server”>

    <title>Untitled Page</title>

</head>

<body>

   <form action=”webform1.aspx”
method=”post” >

   First name: <input type=”text” name=”fname” /><br />

   Last name: <input type=”text” name=”lname” /><br />

   Age: <input type=”text” name=”age” /><br />

   <input type=”submit” value=”Submit” />

 </form>

</body>

</html>

  • We cannot access the variables from the url.

http://localhost:50920/webform1.aspx
澳门新葡亰平台游戏网站 2

 

  • We can access the variables from the
    request. Form [].

  protected void Page_Load(object sender, EventArgs e)

        {

            if (Request.Form[“fname”] != null)

            {

                Response.Write(“fname : ” + Request.Form[“fname”] +
“n”);

            }

            if (Request.Form[“lname”] != null)

            {

                Response.Write(“lname : ” + Request.Form[“lname”] +
“”);

            }

        }

 

The GET Method

Note that the query string (name/value pairs) is sent in the URL of a
GET request:

/test/demo_form.php?name1=value1&name2=value2

Some other notes on GET requests:

  • GET requests can be cached
  • GET requests remain in the browser history
  • GET requests can be bookmarked
  • GET requests should never be used when dealing with sensitive data
  • GET requests have length restrictions
  • GET requests should be used only to retrieve data

The POST Method

Note that the query string (name/value pairs) is sent in the HTTP
message body of a POST request:

POST /test/demo_form.php HTTP/1.1
Host: w3schools.com
name1=value1&name2=value2

Some other notes on POST requests:

  • POST requests are never cached
  • POST requests do not remain in the browser history
  • POST requests cannot be bookmarked
  • POST requests have no restrictions on data length

 

POST is more secure than GET for a couple of reasons.

GET parameters are passed via URL. This means that parameters are stored
in server logs, and browser history. When using GET, it makes it very
easy to alter the data being submitted the the server as well, as it is
right there in the address bar to play with.

The problem when comparing security between the two is that POST may
deter the casual user, but will do nothing to stop someone with
malicious intent. It is very easy to fake POST requests, and shouldn’t
be trusted outright.

The biggest security issue with GET is not malicious intent of the
end-user, but by a third party sending a link to the end-user. I cannot
email you a link that will force a POST request, but I most certainly
can send you a link with a malicious GET request. I.E:

Click Here for the best free
movies!

Edit:

I just wanted to mention that you should probably use POST for most of
your data. You would only want to use GET for parameters that should be
shared with others, i.e: /viewprofile.php?id=1234,
/googlemaps.php?lat=xxxxxxx&lon=xxxxxxx

 

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图